1,确保数组长度 let array = Array(3).fill(''); console.log(array);// ["", "", ""] 2,获取数组最后一项 let array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; console.log(array.slice(-1)); // [9] 3,数组去重 var array = [1, 2, 1, 1, '1']; (1) Array.from(new Set(array));// [1, 2, "1"] (2)[...new Set(array)]// [1, 2, "1"] 4,数组合并 var arr1 = [1,2,3,4] var arr2 = [5,6,7,8] (1)console.log(arr1.concat(arr2))//[1, 2, 3, 4, 5, 6, 7, 8] (2)for(var i=0;i<arr2.length;i++){ arr1.push(arr2[i]); } console.log(arr1)//[1, 2, 3, 4, 5, 6, 7, 8] 5,对象合并 (1) var obj={a:1,b:2}; var cObj = Object.assign({c:3},obj); console.log(cObj);//{c: 3, a: 1, b: 2} (2) var o1 ={a:1}; var o2={b:2}; var o3={c:3}; var obj = Object.assign(o1,o2,o3); console.log(obj)//{a:1,b:2,c:3}