Skip to content

Instantly share code, notes, and snippets.

@bobdobbalina
Last active June 3, 2020 14:36
Show Gist options
  • Select an option

  • Save bobdobbalina/a7a8e679fe61517b4f80d172f70e105b to your computer and use it in GitHub Desktop.

Select an option

Save bobdobbalina/a7a8e679fe61517b4f80d172f70e105b to your computer and use it in GitHub Desktop.
Javascript: Get Unique Values From An Array
const array = [1, 1, 2, 3, 5, 5, 1]
const uniqueArray = [...new Set(array)];
console.log(uniqueArray); // Result: [1, 2, 3, 5]
// OR
let uniqueArray = [...new Set([1, 2, 3, 3,3,"school","school",'ball',false,false,true,true])];
>>> [1, 2, 3, "school", "ball", false, true]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment