Skip to content

Instantly share code, notes, and snippets.

@RinatMullayanov
Created September 3, 2015 06:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RinatMullayanov/e730dc49b939f5793c39 to your computer and use it in GitHub Desktop.
Save RinatMullayanov/e730dc49b939f5793c39 to your computer and use it in GitHub Desktop.
ES 2015 Map sample based on http://learn.javascript.ru/set-map
(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