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

JavaScript uses split to split string into array

高洛峰
Release: 2016-11-28 13:58:04
Original
1650 people have browsed it

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


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template