Skip to content

Instantly share code, notes, and snippets.

@ma-9
Created November 1, 2019 18:27
Show Gist options
  • Save ma-9/fab49b7913aed50f72d260489bb2d28d to your computer and use it in GitHub Desktop.
Save ma-9/fab49b7913aed50f72d260489bb2d28d to your computer and use it in GitHub Desktop.
JavaScript ES8 Features (MAP & SET)
// MAP and SET method of array in JavaScript
// Set removes all duplicate elements from the array
const array = [1,2,3,4,5,5,5,1,1,2,4,2,6,3,7];
const setArray = new Set(array);
// console.log(setArray);
const uniqueArray = [...setArray];
// uniqueArray.push(6);
// setArray.add(8);
// setArray.delete(3);
// setArray.clear();
// console.log(setArray.has(40));
// console.log(setArray.size);
// console.log(uniqueArray.length);
console.log(setArray);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment