标签:array color set null 一个 ring 更新 对象类型 函数
1,过滤唯一值
ES6中的set对象类型,配合展开操作...一起,可以使用它来创建新数组,使得该数组只有唯一的值。
eg.
const array = [1, 1, 2, 3, 5, 5, 1] const uniqueArray = [...new Set(array)]; console.log(uniqueArray); // Result: [1, 2, 3, 5]
此方法适用于包含基本类型的数组:undefined,null,boolean,string和number。 (如果你有一个包含对象,函数或其他数组的数组,你需要一个不同的方法!)
后续更新
标签:array color set null 一个 ring 更新 对象类型 函数
原文地址:https://www.cnblogs.com/tiramisu-lizi/p/10928872.html