Live data from Hacker News

ES6 Maps are now on by default in Chrome 38

programming.com

11–20 of 54 posts

Re: ES6 Maps are now on by default in Chrome 38

#11

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`.

The map constructor simply takes an iterable.

Re: ES6 Maps are now on by default in Chrome 38

#13

Practically 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

#16

Practically 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

I've searched but can't find the answer... Do they maintain insertion order?

Re: ES6 Maps are now on by default in Chrome 38

#17

Practically 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.

This is just a contrived example. In this situation there are a small number of keys that are all known in advance, which is exactly what object literals are for. A map would be more appropriate in situations where you have a large number of keys that are built up at runtime. Similarly, it is the latter situation where the ability to enumerate is important.

Re: ES6 Maps are now on by default in Chrome 38

#20
post #4

That 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

The syntax they have there is creating an array of arrays, and then passing that to the Map constructor, like you suspect. But it wouldn't be possible to make that syntax produce a Map directly -- if it did, how would you produce an array of arrays?

EDIT: My mistake, I misunderstood what you were saying.

Post reply on HN