string to arr code example
Example 1: string to array javascript
const str = 'Hello!';
console.log(Array.from(str));
Example 2: js string to array
var myString = 'no,u';
var MyArray = myString.split(',');
Example 3: convert a string to array in javascript
str = 'How are you doing today?';
console.log(str.split(" "));
Example 4: javascript turn string into array
var fruits = 'apple, orange, pear, banana, raspberry, peach';
var ar = fruits.split(', ');
console.log( ar );
Example 5: convert matrix string to matrix javascript
string = '[[1, 2], [3, 4], [5, 6]]'
string = JSON.parse(string)