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

97
Vistas
Javascript bind polyfill function with return value

I have tried making bind polyfill using this link

It works fine when I use "console.log". But when I return something from the function, it returns undefined

Code:

let person1 = {
  name: "John",
  age: 25,
};

let showDetails = function () {
  let y = `${this.name} - ${this.age}`;
  // console.log(y) -> works fine
  return y;
};

Function.prototype.myBind = function (...args) {
  let that = this;
  params = args.slice(1);
  return function (...args1) {
    that.apply(args[0], [...params, ...args1]);
  };
};

let showDetailsBind = showDetails.myBind(person1);
console.log(showDetailsBind()); // returns -> undefined

Problem with this polyfill is, default bind function works completely fine with same procedure.

about 4 years ago · Santiago Trujillo
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