_.uniq
Produces a duplicate-free version of the array, using === to test object equality.
- // Underscore/Lodash
- var array = [1, 2, 1, 4, 1, 3]
- var result = _.uniq(array)
- console.log(result)
- // output: [1, 2, 4, 3]
- // Native
- var array = [1, 2, 1, 4, 1, 3];
- var result = [...new Set(array)];
- console.log(result)
- // output: [1, 2, 4, 3]
Browser Support for Spread in array literals
46.0 ✔ | 12.0 ✔ | 16.0 ✔ | ✖ | 37.0 ✔ | 8.0 ✔ |
当前内容版权归 you-dont-need 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 you-dont-need .