Function.prototype.myCall = function(cnx) {
let context = cnx || this;
let fn = this;
context.fn = fn;
let result = eval("context.fn("+arguments+")");
delete context.fn;
return result;
}
Function.prototype.myApply = function(cnx, arr) {
let context = cnx || this;
let fn = this;
context.fn = fn;
let result = eval("context.fn("+arr+")");
delete context.fn;
return result;
}
Function.prototype.myBind = function(cnx, arr) {
let context = cnx || this;
context.fn = this;
let args = arr.concat();
return function() {
let result = eval("context.fn("+arr+")");
delete context.fn;
return result;
}
}
const numbers = [5, 6, 2, 3, 7];
const max = Math.max.myApply(null, numbers);
const maxFn = Math.max.myBind(null, numbers);
console.log(max);
console.log(maxFn());
console