4 ms·
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
by z1mm32m4n 12y ago
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`.
- masklinn 12y agoThe map constructor simply takes an iterable.
- nawitus 12y agoSomeone asked for this elsewhere, it's really simple. Kinda odd that it's not in the standard, though. EDIT: It's because Maps preserve insertion order, so the standard doesn't advocate use like this. var objectToMap = x => new Map(Object.keys(x).map(o => [o, x[o]]));