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

258
Views
How to get correct callback value

i'm trying to impletent a filter function in js. I have some problems. If i only have one argument, it works fine:

const filteredNumbers = numbers.filter((item) => item > 10)

When i try to use 2 or 3 arguments the problems start here:

const filteredNumbers = numbers.filter((item, i, arr) => arr === numbers)

How can i know, which argument is using for comparison to filter? For example:

const filteredNumbers = numbers.filter((item, index) => index > 0)

As we can see, index > 0, not item variable. How can i know in code, which value is used?

numbers.filter = function(callback, index, array) {
  const result = [];
  let count = 0;

  for (let i = 0; i < this.length; i++) {
    if (callback(this[i])) {
      result[count] = this[i];
      count++;
    }
    
  }

  return result;
};

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!