var arr = [3, 4, 5, 6]
arr.push(1) //在数组最后添加一个元素
console.log(arr) //[3,4,5,6,1]
var arr = [3, 4, 5, 6]
arr1 = arr.pop() //把数组的最后一位弹出来,返回
console.log(arr1) //6
console.log(arr) //[3,4,5]
var arr = [3, 4, 5, 6]
arr2 = arr.shift() //把数组的第一位拿出来返回,原数组发生变化
console.log(arr2) //3
console.log(arr) //[4,5,6]
var arr = [3, 4, 5, 6]
arr.unshift(1) //在数组第一位新增
console.log(arr) //[1,3,4,5,6]
var arr = [3, 4, 5, 6]
a = arr.join("-") //把数组元素(对象调用其toString()方法)使用参数作为连接符连接成一字符串,不会修改原数组内容
console.log(arr) //[3,4,5,6]
console.log(a) //"3-4-5-6"
var arr = [3, 4, 5, 6]
arr3 = arr.splice(2,2,1,2,3) //删除,新增,替换数组,(从角标2开始,删除2位,增加数组【1,2,3】,返回删除的数组)
console.log(arr3) //[5,6]
console.log(arr) //[3,4,1,2,3]
var arr = [3, 7, 5, 6]
arr.sort() //给数组按字母表方法排序,元素大于10时需传入自定义排序函数
console.log(arr) //[3,5,6,7]
var arr = [3, 4, 5, 6]
arr.reverset() //将数组逆序
console.log(arr) //[6,5,4,3]
var arr = [3, 4]
var arr5 = [5, 6]
var arr6 = arr.concat(arr5) //拼接数组,但不会改变原数组,返回新的数组
console.log(arr) //[3,4]
console.log(arr5) //[5,6]
console.log(arr6) //[3,4,5,6]