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

263
Visualizações
Javascript how do i dynamically find keys in my array?

I'm trying to find all the keys that are in my array to figure out if some keys already exist in there. Tho when I try to put in the keys seperate like this:

console.log(this.UrlArray.find(({color_ids}) => color_ids));

It works, but if I try doing it with the variable with the actual keys in it:

console.log(this.UrlArray.find(({prefixEqual}) => prefixEqual));

It doesn't work. The values that belong to the keys aren't important, but I stil can't figure out how to do it.

Array example:

(3) [{…}, {…}, {…}]
  0:
    bd_shoe_size_ids: Array(2)
      0: "6601"
      1: "6598"
    length: 2
    [[Prototype]]: Array(0)
    [[Prototype]]: Object
  1:
    color_ids: Array(2)
      0: "6056"
      1: "6044"
    length: 2
    [[Prototype]]: Array(0)
    [[Prototype]]: Object
  2:
    manufacturer_ids: Array(2)
      0: "5875"
      1: "5866"
    length: 2
    [[Prototype]]: Array(0)
    [[Prototype]]: Object
  length: 3
[[Prototype]]: Array(0)

I asked something like this before, but I got linkes to answers that had nothing to do with what I'm trying to do and it closed.

As desired outputs I just wanna see bd_shoe_size_ids, color_ids and manufacturer_ids when I console log it.

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

0

const data = [
    { bd_shoe_size_ids: [1, 2] },
    { color_ids: [3, 4] },
    { manufacturer_ids: [5, 6] },
];

const output = data.map(Object.keys).flat();

console.log(output);

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