js分割字符串

.split()

var str ="How are you doing today?";
document.write(str.split(" ") + "
") document.write(str.split("") + "
") document.write(str.split(" ",3))

输出

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

你可能感兴趣的:(js分割字符串)