how to convert string to array js code example

Example 1: string to array javascript

const str = 'Hello!';

console.log(Array.from(str)); //  ["H", "e", "l", "l", "o", "!"]

Example 2: js string to array

var myString = 'no,u';
var MyArray = myString.split(',');//splits the text up in chunks

Example 3: string to array javascript

const string = "Hello!";

console.log([...string]); // ["H", "e", "l", "l", "o", "!"]

Example 4: how to change string to array in javascript

a=anyElement.all

// console.log(a)
Array.from(a).forEach(function (element){
    console.log(element)
})

Tags:

Php Example