Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,22 @@
|
|||
var map = new Map(),
|
||||
fn = function () {},
|
||||
obj = {};
|
||||
|
||||
map.set(fn, 123);
|
||||
map.set(obj, 'abc');
|
||||
map.set('key', 'val');
|
||||
map.set(3, x => x + x);
|
||||
|
||||
map.get(fn); //=> 123
|
||||
map.get(function () {}); //=> undefined because not the same function
|
||||
map.get(obj); //=> 'abc'
|
||||
map.get({}); //=> undefined because not the same object
|
||||
map.get('key'); //=> 'val'
|
||||
map.get(3); //=> (x => x + x)
|
||||
|
||||
map.size; //=> 4
|
||||
|
||||
//iterating using ES6 for..of syntax
|
||||
for (var key of map.keys()) {
|
||||
console.log(key + ' => ' + map.get(key));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue