I want to create a array of strings by appending, but it matters if the origin is an array or yet a string. Therefore I need to convert a string like "abc" to a string array.
if I use
Array.from()
it makes me something like this ["a","b","c"] but I want to have ["abc"];
Is there a easy way that takes an input like "abc" and at the same time ["a","abc"] I so that I can append later one one more string with push for example?
some constraints: I cannot create
let a = [];
because it is coming from extern. And sure, I can add some code to check what is its, but I search for a simple mechanism.
I think i need something like arr1.flat();
let a = []; a.push("abc");is that what you want?array.reduce((array, entry) => [(array[0] ?? '') + entry], '');[array.join('')]. Good luck