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

260
Vistas
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
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