Home >Web Front-end >JS Tutorial >JavaScript uses split to split string into array
Array:
var arrA = new Array(); //Declare the array
split:
1. In this example, we will split the string in different ways:
Output:
How,are,you,doing,today? H ,o,w, ,a,r,e, ,y,o,u, ,d,o,i,n,g, ,t,o,d,a,y,? How,are,you
2. When you want to split the file path into an array with "", you need to write like this
var split1=new Array();
split1= myFile.toString().split("\");----- -----------------------------Separate file names with ""
alert(split1[0]);