Home >Web Front-end >JS Tutorial >JavaScript uses split to split string into array

JavaScript uses split to split string into array

高洛峰
高洛峰Original
2016-11-28 13:58:041651browse

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]);


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn