Skip to content

Instantly share code, notes, and snippets.

@kopylovvlad
Created April 30, 2017 12:16
Show Gist options
  • Select an option

  • Save kopylovvlad/7e41e057571a3b9572fc900ac3956a36 to your computer and use it in GitHub Desktop.

Select an option

Save kopylovvlad/7e41e057571a3b9572fc900ac3956a36 to your computer and use it in GitHub Desktop.
'use strict'
let groceryList = new Set()
groceryList
.add('Bananas')
.add('Apples')
.add('Grapes')
.add('Kiwis')
.add('Pears')
.add('Apples') // dublicates will be ignored
console.log(groceryList.size === 5)
console.log(groceryList.has('Kiwis') === true)
for (let item of groceryList) {
console.log(item)
}
console.log(groceryList.size === 5)
groceryList.delete('Kiwis')
console.log(groceryList.size === 4)
groceryList.clear()
console.log(groceryList.size === 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment