JS之字符串操作

split() 按指定分隔符将字符串分割为数组

var s = "This is a dog."
var arr = [];
arr = s.split(' ');

arr : ["This","is","a","dog."] 

join() 把数组转换成字符串,里面的每一个元素可以用你指定的连接符来连接起来,这个连接符就是你要传入的参数。

var arr  =  ["This","is","a","dog."] ;
var s = arr.join(' ');
s :"This is a dog."

你可能感兴趣的:(JS之字符串操作)