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

129
Views
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
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!