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

130
Vistas
JS - Map/Array choice when both can do the same task

This is probably more of an opinion based question. But recently on a project I have seen that Map is always used over array.

My question is when would you ever use an array over a Map?

Note I mean in cases where an array would work as well as a Map.

i.e. storing data, checking it exists, and deleting it.

example here:

// Array
const teams = [];

if (teams.includes(team.id)) {
  return;
}

teams.push(team.id);

// do stuff

teams = teams.filter(
  (id) => id !== team.id
);


// Map
const teams = new Map();

if (teams.has(team.id)) {
  return;
}

teams.set(team.id, team.id);
// do stuff

teams(team.id);

As I understand Map is more performant, you also get methods like get, set, delete which are useful.

If faced with the task above what would people use and why?

about 4 years ago · Juan Pablo Isaza
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