Created
November 1, 2019 18:27
-
-
Save ma-9/fab49b7913aed50f72d260489bb2d28d to your computer and use it in GitHub Desktop.
JavaScript ES8 Features (MAP & SET)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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