Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

332
Views
Is there any advantage to using Object.create(null) over a Map?

I've seen people use code that looks like

const STUFF_MAP = Object.create(null);

STUFF_MAP would like suggested only be used like a map, so I understand why using Object.create(null) is better than {} (removing the properties that could cause conflicts etc.), but is there any advantage to not just use

const STUFF_MAP = new Map();

When would I use each one? Does it have to do with being compiled to pre es6?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Does it have to do with being compiled to pre es6?

Yes, Object.create(null) is ES5 and won't need a polyfill for Map, if you need to support old browsers.

Apart from that, you should prefer the more modern Map which is also clearly indicates the purpose of a variable. You will need to access the collection using has/get/set methods, not in operator/bracket syntax/assignment. This can sometimes lead to code that isn't as concise, e.g. for incrementing a value you cannot use a compound assignment operator.

As for performance, there should not be much of a difference; if you care, do a benchmark for your particular situation.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!