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

196
Visualizações
How to get key value in this case {Java Script}

Hi so what iam trying to achieve is basically is simple.Iam try to get only the object key's value from the given array so this is my example array

[{'aaa': '11','text':'hello'},{'aaa': '12','text':'bye'}] iam expecting a output of something like this [11,12]

where iam getting the data of the aaa key only

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

This will do what you want, but the order could well change between different javascript implementations

const input = [{'aaa': '11','text':'hello'},{'bbb': '12','text':'bye'}]

const output = input.map(x => Object.values(x)[0]);

console.log(output)


I note you updated the quesrtion to have both the same first key - if you're looking for aaa value from all elements this is much simpler

const input = [{'aaa': '11','text':'hello'},{'aaa': '12','text':'bye'}]

const output = input.map(x => x.aaa);

console.log(output)

about 4 years ago · Juan Pablo Isaza Relatório

0

const o = [{'aaa': '11','text':'hello'},{'aaa': '12','text':'bye'}]

const filtered = o.map(i => +i.aaa)
console.log(filtered)

about 4 years ago · Juan Pablo Isaza Relatório

0

The JSON path if you convert this into a JavaScript Object Notation format (as JSON).

0.aaa = 11

1.bbb = 12

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