DEV Community

loading...

Discussion on: When You Should Use JavaScript Maps over Objects

Collapse
leob profile image
leob

Interesting, nice overview.

In most cases where I needed "lookup" I've used objects rather than maps, I guess it's mostly a matter of familiarity (and in some cases compatibility with older JS versions or older browsers, which may not support Map).

An interesting feature (I wasn't aware of that) is the ordered nature of Maps, I can imagine that that can be very useful.

Are there also performance benefits (especially with regards to lookup) of Map versus Object?

Collapse
reedbarger profile image
Reed Barger Author

Yes, there are some performance benefits as compared to objects, for finding, adding, and deleting entries (with .has(), .set(), and .delete()).

If you want to look more into that, check out this article, which covers how much of a performance boost there is from using maps over normal objects.

Collapse
leob profile image
leob

Thanks! Yes I see it, performance is generally a lot better, good to know.