shift:删除数组的第一项,并返回删除元素的值
var arr1 = [1,2,3,4,5];
var b = arr1.shift();
console.log(arr1); //[2,3,4,5]
console.log(b); //1
pop:删除原数组的末了一项,并返回删除元素的值
var arr1 = [1,2,3,4,5];
var b = arr1.pop();
console.log(arr1); //[1,2,3,4]
console.log(b); //5
unshift:向数组头部追加,返回数组长度
var arr1 = [1,2,3];
var b = arr1.unshift(4,5,6);
console.log(arr1); //[4,5,6,1,2,3]
console.log(b); // 6
push:将参数添加到数组尾部,返回数组长度
var arr1 = [1,2,3];
var b = arr1.push(4,5,6);
console.log(arr1); //[1,2,3,4,5,6]
console.log(b); // 6
concat:返回一个新数组,是将参数添加到原数组中构成的
arr = ['A'];
var b = arr.concat(6,7);
console.log(b); // ['A',6,7]
splice(start,deleteCount,val1,val2,):从start位置最先删除deleteCount项,并从该位置起插进去val1,val2,
var a = [1,2,3,4,5];
var b = a.splice(2,1,111,222,333);
console.log(a); //[ 1, 2, 111, 222, 333, 4, 5 ]
console.log(b); //[3] 返回被删除的内容
slice(start,end);截取字符串 返回截取的从最先下标到完毕下标之间的项构成的新数组
var a = [1,2,3,4,5];
var b = a.slice(2,5);
console.log(a); //[1,2,3,4,5]
console.log(b); //[3,4,5]
join(separator) 数组切割,返回字符串 将数组的元素组起一个字符串,以separator为分隔符,省略的话则用默认用逗号为分隔符
var a = [1,2,3,4,5];
var b = a.join('|');
console.log(a); //a:[1,2,3,4,5]
console.log(b); //b:"1|2|3|4|5"