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
What does "a.call.apply(a.bind, arguments)" mean?

Just because of curiosity I wanted to make a bounded function with this particular approach :

var fn = function(a, b, c) {
    return a.call.apply(a.bind, arguments)
}

var boundFn = function(a, b, c) {
    fn.apply(null, arguments)
}

function unboundedFn() {
    console.log(this, arguments)
}

var boundedFn = boundFn(unboundedFn, x, y);

So I'm trying to understand what a.call.apply(a.bind, arguments) do exactly ?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If You have a function like this:

function unboundedFn() {
    console.log(this, arguments)
}

You can use unboundedFn.call(thisObj, arg1, arg2) or unboundedFn.apply(thisObj, [arg1, arg2]) to run it, but changing what this means inside. Both call and apply do the same, and only difference is way of passing arguments.

Becouse call, apply and also bind are methods, you can run for example unboundedFn.call.call.call.call.apply.apply.apply.apply(), but it doesn't seem to have to much sense.

In your example return a.call.apply(a.bind, arguments) is equal to return a.bind.call(...arguments), which is equal to a.bind(...arguments.slice(1)), so whole fn function can be simplified to:

function fn(a,b,...args){
   return a.bind(b, ...args);
}
about 4 years ago · Juan Pablo Isaza Denunciar
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