Skip to content

Instantly share code, notes, and snippets.

@olehwebdev
Created September 11, 2017 08:17
Show Gist options
  • Save olehwebdev/5bf2801c0a216a5bdd9831d0811a234d to your computer and use it in GitHub Desktop.
Save olehwebdev/5bf2801c0a216a5bdd9831d0811a234d to your computer and use it in GitHub Desktop.
This code returns a new array|object, only unique numbers.
const array = [1,1,2,3,4,5,5,5,6,7,8];
const array2 = new Set(array);
const uniq = [...new Set(array)];
//Unique Array
console.log('Unique array', uniq);
//Unique Object
console.log('Object', array2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment