Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -1,4 +1,22 @@
|
|||
var assoc = {
|
||||
foo: 'bar',
|
||||
'another-key': 3 //the key can either be enclosed by quotes or not
|
||||
};
|
||||
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