Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

174
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda