turning string into array javascript code example
Example 1: convert string to array js
let string = 'ABCDEFG';
let newArray = string.split('');
console.log(newArray);
Example 2: javascript explode
var str = "Well, how, are , we , doing, today";
var res = str.split(",");
Example 3: convert a string to array in javascript
str = 'How are you doing today?';
console.log(str.split(" "));
Example 4: javascript explode space
var str = "my car is red";
var stringArray = str.split(/(\s+)/);
console.log(stringArray);
Example 5: 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);