split string in javascript with space code example
Example 1: js split text on spaces
var string = "text to split";
var words = string.split(" ");
Example 2: javascript explode
//split into array of strings.
var str = "Well, how, are , we , doing, today";
var res = str.split(",");
Example 3: javascript split
// bad example https://stackoverflow.com/questions/6484670/how-do-i-split-a-string-into-an-array-of-characters/38901550
var arr = foo.split('');
console.log(arr); // ["s", "o", "m", "e", "s", "t", "r", "i", "n", "g"]