split() join(") reverse()
1.split() 字符串拆分
将一个字符串按 - 拆分
var dateStr='2015-1-5';
console.log(dateStr.split('-'));
输出结果:2015 1 5
将把一个字符串分割成数组
var str="How are you ?";
var n=str.split(" ");
输出结果:["How", "are", "you", "?"]
2.join('')字符串连接
把数组中的所有元素连接为一个字符串
var fruits = ["Banana", "Orange", "Apple", "Mango"];
console.log(fruits.join());
输出结果:Banana,Orange,Apple,Mango
3.reverse()颠倒数组中的元素
颠倒数组中元素的顺序
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.reverse();
输出结果:["Mango", "Apple", "Orange", "Banana"]