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

173
Visualizações
Why is my filter function only working when it has two arguments, even though one argument is missing?

Essentially what I am trying to accomplish is to filter out only the indices I need. However I noticed that it only works when passing BOTH filter(v,i) into the method, even though v is never used! At first I believed this was a scoping issue, but v is never declared globally.

The computation below works fine:

 wordObj.wordKeys[0] = wordObj.wordKeys[0].filter((v, i) => {
    return indiciesToKeep.includes(i);
  });  

However, this computation without "v" does not:

 wordObj.wordKeys[0] = wordObj.wordKeys[0].filter((i) => {
    return indiciesToKeep.includes(i);
  }); 

It is not throwing any syntax errors. It is simply just not returning the correct indices when I don't pass "v" into function. Any ideas on why this may not work would be greatly appreciated

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