Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

334
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda