方法一: Es6 Array.from方法可以将Set结构转为数组。
方法二:
方法三:数组includes属性
方法四:filter()方法用于把Array中的某些元素过滤掉,然后返回剩下的未被过滤掉的元素。
注意:①filter不会对空数组进行检测; ②filter不会改变原始数组。
语法:array.filter(function(currentValue, index, arr), thisValue);
currentValue 必须。当前元素的值
index 可选。当前元素的索引值
arr 可选。当前元素属于的数组对象
thisValue 可选。要传递给函数以用作其“this”值的值。如果此参数为空,则值“undefined”将作为其“this“值传递。
返回值:包含所有通过测试的数组元素的数组。如果没有元素通过测试,则返回一个空数组。
indexOf()索引方法返回-1表示不存在