separate string by character js code example
Example 1: string split javascript
var myString = "An,array,in,a,string,separated,by,a,comma";
var myArray = myString.split(",");
/*
*
* myArray :
* ['An', 'array', 'in', 'a', 'string', 'separated', 'by', 'a', 'comma']
*
*/
Example 2: js split string
var myString = "Hello World!";
// splitWords is an array
// [Hello,World!]
var splitWords = myString.split(" ");
// e.g. you can use it as an index or remove a specific word:
var hello = splitWords[splitWords.indexOf("Hello")];