(lodash_gcy)unique—移除数组中的相同元素
2017-02-28 23:33
253 查看
/** * 移除数组中的相同元素 * * @returns {array} 返回处理后的数组 * * @example * * [1,2,3,1,2].unique(); * //=> [1,2,3] * */ function unique() { let temArr = []; this.forEach((item)=>{ if (!(temArr.indexOf(item) + 1)) { //indexOf无法判断NaN的情况 if (Number.isNaN(item)){ if (!temArr.hasNaN()) temArr.push(item) }else temArr.push(item) } }); return temArr } module.exports = unique;
相关文章推荐
- 2、(lodash_gcy)移除数组指定元素—remove
- 3、(lodash_gcy)移除数组中的假值元素
- jquery 移除数组重复的元素----$.unique()
- 删除数组中相同元素[等同内置函array_unique]
- (lodash_gcy)union—将给定的几个数组的唯一元素组合成一个数组
- (lodash_gcy)hasAttr——判断数组中是否存在某个元素
- 移除数组中相同元素
- 返回两个数组中非相同的元素
- Leetcode 80. Remove Duplicates from Sorted Array II(从已排序数组中移除重复元素)
- 去除javascript数组中的相同元素
- Remove duplicates from Array移除数组重复元素
- php 移除数组重复元素的一点说明
- 找两个数组中的相同元素
- 移除数组中重复元素
- LeetCode27——Remove Element(移除数组中指定的元素)
- 用HashSet查找两个int数组中的相同元素
- 请教一个算法问题,有两个数组A,B,判断A中是否至少有一个元素和B中元素相同
- 两个有序的数组,挑选出相同的元素
- 找出两个数组中相同的元素,不排序直接两次循环取出
- js移除数组中的元素