Skip to content

Instantly share code, notes, and snippets.

@kopylovvlad
Created April 30, 2017 12:16
Show Gist options
  • Save kopylovvlad/4b68dbea4d1356b25ae7165ed7545549 to your computer and use it in GitHub Desktop.
Save kopylovvlad/4b68dbea4d1356b25ae7165ed7545549 to your computer and use it in GitHub Desktop.
groceryList = {}
groceryList['Bananas'] = true
groceryList['Apples'] = true
groceryList['Grapes'] = true
groceryList['Kiwis'] = true
groceryList['Pears'] = true
groceryList['Apples'] = true # dublicates will be ignored
console.log(Object.keys(groceryList).length == 5)
console.log(groceryList['Kiwis'] == true)
for key of groceryList
console.log(key) if groceryList.hasOwnProperty(key)
console.log(Object.keys(groceryList).length == 5)
delete groceryList['Kiwis']
console.log(Object.keys(groceryList).length == 4)
for key of groceryList
delete groceryList[key]
console.log(Object.keys(groceryList).length == 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment