how to change an string to an array in javascript code example

Example 1: convert a string to array in javascript

// Designed by shola for shola

str = 'How are you doing today?';
console.log(str.split(" "));

//try console.log(str.split(""));  with no space in the split function
//try console.log(str.split(","));  with a comma in the split function

Example 2: how to change string to array in javascript

a=anyElement.all

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

Tags:

Java Example