Skip to content

Instantly share code, notes, and snippets.

@kopylovvlad
Created April 30, 2017 12:18
Show Gist options
  • Save kopylovvlad/f9aa63e308e7faf6e7afa657781204b7 to your computer and use it in GitHub Desktop.
Save kopylovvlad/f9aa63e308e7faf6e7afa657781204b7 to your computer and use it in GitHub Desktop.
'use strict'
let groceryList = new Map()
groceryList.set('Bananas', 6)
groceryList.set('Apples', 12)
groceryList.set('Grapes', 2)
groceryList.set('Kiwis', 10)
groceryList.set('Pears', 8)
console.log(groceryList.get('Kiwis') === 10)
console.log(groceryList.size === 5)
for (let [ key, val ] of groceryList.entries())
console.log(`${key} = ${val}`)
groceryList.delete('Apples')
console.log(groceryList.size === 4)
console.log(...groceryList.values())
console.log(...groceryList.keys())
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