convert string to array javascript split code example
Example 1: javascript explode
var str = "Well, how, are , we , doing, today";
var res = str.split(",");
Example 2: javascript slice string from character
var input = 'john smith~123 Street~Apt 4~New York~NY~12345';
var fields = input.split('~');
var name = fields[0];
var street = fields[1];
Example 3: javascript explode space
var str = "my car is red";
var stringArray = str.split(/(\s+)/);
console.log(stringArray);
Example 4: split array javascript
arr.slice(start, end);
Example 5: parse string javascript
parseFloat("16.5");
parseInt("34.6");
JSON.parse('{ "name":"John", "age":30, "city":"New York"}');
Example 6: how to split a string in javascript
strName.split();