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

354
Views
true call polyfil (sin operadores de propagación/descanso); bono: aplicar y enlazar polyfills

He estado practicando call, apply, bind polyfills y de repente me di cuenta de que no es realmente un polyfill si uso operadores de propagación/descanso, no puedo entender cómo pasar argumentos en call sin él, ¿alguna idea amigos?

 //my attempt to write call polyfil without spread operator //but it doesn't work Function.prototype.call = function () { const obj = arguments[0]; obj.fn = this; const args = Array(arguments).slice(1).reverse(); while (args.length) { obj.fn.arguments.push(args.pop()); } //obj.fn.arguments = Array(arguments).slice(1); obj.fn(); }; // that one works, but it uses spread operator Function.prototype.call = function (obj, ...args) { obj.fn = this; obj.fn(...args); }; Function.prototype.apply = function (obj, args) { obj.fn = this; obj.fn(...args); }; Function.prototype.myBind = function (obj, ...args) { const fn = this; return function (...newArgs) { const allArgs = [...args, ...newArgs]; fn.call(obj, ...allArgs); //fn.apply(obj, allArgs); }; }; let obj = { name: "Jack", }; let myFunc = function (id, city) { console.log(`${this.name}, ${id}, ${city}`); }; let newFunc = myFunc.myBind(obj, "a_random_id"); newFunc("New York"); // Jack, a_random_id, New York
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!