Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2015
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. (function () {
  2. 'use strict';
  3.  
  4. let map = new Map();
  5.  
  6. map.set('1', 'str1'); // key: string
  7. map.set(1, 'num1'); // key: number
  8. map.set(true, 'bool1'); // key: bool
  9.  
  10. // in ordinary objects that would be the same,
  11. // map retains key type
  12. console.log( map.get(1) ); // 'num1'
  13. console.log( map.get('1') ); // 'str1'
  14.  
  15. console.log( map.size ); // 3
  16. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement