// 1、数组拼接 concat() var a = [1, 2]; var b = [3, 4]; console.log(a.concat(b)); // [1, 2, 3, 4] // 2、数组翻转 reverse() var a = [1, 2, 3]; console.log(a.reverse()); // [3, 2, 1] // 3、数组分割 slice() var a = [1, 2, 3, 4]; console.log(a.slice(1, 3)); // [2, 3] // 4、数组替换 splice() var a = [1, 2, 3, 4, 5]; a.splice(2, 2, "a"); console.log(a); // [1, 2, "a", 5] // 5、数组排序 sort() var a = [2, 1, 3]; a.sort(); console.log(a); // [1, 2, 3]
原文地址:https://www.cnblogs.com/GetcharZp/p/12066901.html
时间: 2024-10-21 14:36:35