Created
November 3, 2014 01:25
-
-
Save jimschubert/cc68e5fb4a904126357a to your computer and use it in GitHub Desktop.
Why use ES6 Map?
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
$ node --harmony | |
> var person = { name: "Jim", age: 34 }; | |
undefined | |
> var map = new Map() | |
undefined | |
> map.set(person, 'JavaScript'); | |
undefined | |
> person.name = "James"; | |
'James' | |
> map.get(person) | |
'JavaScript' | |
> var interests = {}; | |
undefined | |
> interests[person.name] = 'JavaScript'; | |
'JavaScript' | |
> person.name = "Jim"; | |
'Jim' | |
> interests[person.name]; | |
undefined | |
> interests["James"]; | |
'JavaScript' | |
> exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment