how to convert string to char array javascript code example
Example 1: string to char array in javascript
const string = 'hi there';
const usingSplit = string.split('');
const usingSpread = [...string];
const usingArrayFrom = Array.from(string);
const usingObjectAssign = Object.assign([], string);
// Result
// [ 'h', 'i', ' ', 't', 'h', 'e', 'r', 'e' ]
Example 2: string to array javascript
const str = 'Hello!';
console.log(Array.from(str)); // ["H", "e", "l", "l", "o", "!"]