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

94
Views
JS: is there a way to adhere to an order using a Map?

I want to use a map to store some data but I want to preserve the order in which they come from the API array:

let people = [{ name: "jordan", age: 33}, { name: "rich", age: 23} ]; // comes from API

let map = new Map();

for (let x = 0; x < people.length; x++) {
     map.set(person.name, person.age) 
}

I now have a map of those:

// console.log(map) 

// Map(2) {'jordan' => 33, 'rich' => 23}

if I iterate through that map later on using a for of loop, is the order of the Entries guaranteed in that I would be sure the first age would always be 33?

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!