Goodbye object literals too, apparently.
I can potentially imagine a helper function like `mapFromObject`, but yeah I agree with you. That syntax is disheartening. Enough to make me want to keep using `hasOwnProperty`.
ES6 Maps are now on by default in Chrome 38
11–20 of 54 posts
Re: ES6 Maps are now on by default in Chrome 38
#12That looks like a cumbersome way to define a map, like small arrays within arrays.
Re: ES6 Maps are now on by default in Chrome 38
#13Practically a net neutral time saved in typing at the cost of readability of the object literal. I don't think there will be many cases where I'll be using Map over an Object literal.
* they have a length
* their keys are typed, not limited to strings. Objects as keys actually works
* they can be cleared in a single call
* they can easily be iterated over keys, values or (key, value) pairs
Re: ES6 Maps are now on by default in Chrome 38
#14var map = {a: '1', b: '2'}
Object.keys(map).forEach(function(k) { console.log(map[k]) })
Re: ES6 Maps are now on by default in Chrome 38
#15Re: ES6 Maps are now on by default in Chrome 38
#16Practically a net neutral time saved in typing at the cost of readability of the object literal. I don't think there will be many cases where I'll be using Map over an Object literal.
Maps have quite a few advantages over bare objects: * they have a length * their keys are typed, not limited to strings. Objects as keys actually works * they can be cleared in a single call * they can easily be iterated over keys, values or (key, value) pairs
Re: ES6 Maps are now on by default in Chrome 38
#17Practically a net neutral time saved in typing at the cost of readability of the object literal. I don't think there will be many cases where I'll be using Map over an Object literal.
Re: ES6 Maps are now on by default in Chrome 38
#18Of course you could already use prototype-less objects as maps (Object.create(null))
Maps allows object keys, which could be really handy in many situations.
Re: ES6 Maps are now on by default in Chrome 38
#19 var map = { "__proto__": 1, "a":2 ,"b":3 };
for (var key in map) if(map.hasOwnProperty(key)) {
console.log(map[key]);
}Re: ES6 Maps are now on by default in Chrome 38
#20That looks like a cumbersome way to define a map, like small arrays within arrays.
Hummm My bet is that the Map() is turning an array of arrays into a map. And that in the future it will convert the original syntax into a Map as well
EDIT: My mistake, I misunderstood what you were saying.