js 对数组的操作

1,判断数组中是否存在值 includes属性

const array1 = [1, 2, 3];

console.log(array1.includes(2));
结果: true

2,合并数组  concat() 

这种方法可以合并两个或多个数组。此方法不会改变现有数组,可组合返回一个新数组。

const array1 = ['a', 'b', 'c'];
const array2 = ['d', 'e', 'f'];

console.log(array1.concat(array2))

结果 Array ["a", "b", "c", "d", "e", "f"]

posted @ 2021-06-28 09:29  魔法少女郭德纲啊  阅读(40)  评论(0)    收藏  举报