js parse string to array code example
Example 1: convert string to array js
let string = 'ABCDEFG';
let newArray = string.split('');
console.log(newArray);
Example 2: string split javascript
var myString = "An,array,in,a,string,separated,by,a,comma";
var myArray = myString.split(",");
Example 3: js string to array
str = 'How are you doing today?';
console.log(str.split(' '));
>> (5) ["How", "are", "you", "doing", "today?"]
Example 4: convert string to array javascript
let myArray = str.split(" ");
Example 5: string to array javascript
const string = "Hello!";
console.log([...string]);
Example 6: convert string to array js
function f() {
return Array.from(arguments);
}
f(1, 2, 3);
const s = new Set(["toto", "truc", "truc", "bidule"]);
Array.from(s);
const m = new Map([[1, 2], [2, 4], [4, 8]]);
Array.from(m);
const mapper = new Map([["1", "a"], ["2", "b"]]);
Array.from(mapper.values());
Array.from(mapper.keys());
Array.from("toto");
Array.from([1, 2, 3], x => x + x);
Array.from({length: 5}, (v, k) => k);