JavaScript prototype addTen

Function.prototype.myBind = function (...args) {
  const func = this;
  return function (...innerArgs) {
    return func.apply(this, args.concat(innerArgs));
  };
};

function add(num1, num2) {
  return num1 + num2;
}

const addTen = add.myBind(10);

console.log(addTen(5)); // Now it should return 15

Leave a Comment