Skip to content

Instantly share code, notes, and snippets.

@epjuan21
Last active October 21, 2019 15:08
Show Gist options
  • Save epjuan21/4bbaff5c1dc6d1f451b2223623534986 to your computer and use it in GitHub Desktop.
Save epjuan21/4bbaff5c1dc6d1f451b2223623534986 to your computer and use it in GitHub Desktop.
Remove Duplicates From Array
// Remove Duplicates From Array
var fruits = [“banana”, “apple”, “orange”, “watermelon”, “apple”, “orange”, “grape”, “apple”];
// First method
var uniqueFruits = Array.from(new Set(fruits));
console.log(uniqueFruits); // returns [“banana”, “apple”, “orange”, “watermelon”, “grape”]
// Second method
var uniqueFruits2 = […new Set(fruits)];
console.log(uniqueFruits2); // returns [“banana”, “apple”, “orange”, “watermelon”, “grape”]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment