Created
September 3, 2015 06:43
-
-
Save RinatMullayanov/e730dc49b939f5793c39 to your computer and use it in GitHub Desktop.
ES 2015 Map sample based on http://learn.javascript.ru/set-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
(function () { | |
'use strict'; | |
let map = new Map(); | |
map.set('1', 'str1'); // key: string | |
map.set(1, 'num1'); // key: number | |
map.set(true, 'bool1'); // key: bool | |
// in ordinary objects that would be the same, | |
// map retains key type | |
console.log( map.get(1) ); // 'num1' | |
console.log( map.get('1') ); // 'str1' | |
console.log( map.size ); // 3 | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment