_.uniq

Produces a duplicate-free version of the array, using === to test object equality.

  1. // Underscore/Lodash
  2. var array = [1, 2, 1, 4, 1, 3]
  3. var result = _.uniq(array)
  4. console.log(result)
  5. // output: [1, 2, 4, 3]
  6.  
  7. // Native
  8. var array = [1, 2, 1, 4, 1, 3];
  9. var result = [...new Set(array)];
  10. console.log(result)
  11. // output: [1, 2, 4, 3]

Browser Support for Spread in array literals

ChromeEdgeFirefoxIEOperaSafari
46.0 ✔12.0 ✔16.0 ✔37.0 ✔8.0 ✔