Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

105
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda