string convert to array javascript code example
Example 1: convert string to array js
let string = 'ABCDEFG';
let newArray = string.split('');
console.log(newArray);
Example 2: javascript convert to array
console.log(Array.from('foo'));
console.log(Array.from([1, 2, 3], x => x + x));
Example 3: convert string to array javascript
const string = 'hi there';
const usingSplit = string.split('');
const usingSpread = [...string];
const usingArrayFrom = Array.from(string);
const usingObjectAssign = Object.assign([], string);