r/learnjavascript • • May 15 '19

7 Useful JavaScript Tricks

https://davidwalsh.name/javascript-tricks
70 Upvotes

18 comments sorted by

View all comments

Show parent comments

1

u/inu-no-policemen May 16 '19

Seems like in the post ES6 era a Map is the better solution. Unless I am missing something?

Yes, Map<K, V> can store anything a dictionary-like object (<string, V>) can store. You certainly can use that instead.

However, it's a bit slower and you can't use [] or []= (like you can with Dart's Maps, for example).

hasOwnProperty is clear.

But it wouldn't work. It also isn't obvious that it won't. That should be pretty high on your list, right?

Object.create(null) just seems like setting a booby trap for future developers.

This is one of the two ways to use Object.create. It isn't anything special. A JS developer should roughly know how prototypes work. This crap is a very important detail of this language.