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

96
Views
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
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!