how to split a string into an array javascript 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: split array javascript

// Returns new array from exising one
arr.slice(start, end);

Example 3: in javascript how to split string

var str = 'It iS a 5r&e@@t Day.'
var array = str.split(" ");
print(array);

var str = 'It iS a 5r&e@@t Day.'
var array = str.split(" ",2);
print(array);

Example 4: HOW TO SPLIT AN ARRAY JAVASCRIPT

array.splice(index, number, item1, ....., itemN)

Example 5: how to split a string in javascript

strName.split(); // My code

Tags:

Php Example