Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!