apply
Function.prototype.myApply = function(context,args){
const fn = this
context.fn = fn
let res = context.fn(...args)
delete context.fn
return res
}
call
Function.prototype.myCall = function(context,...args){
const fn = this
context.fn = fn
let res =context.fn(...args)
delete context.fn
return res
}
bind
Function.prototype.myBind = function(context){
const fn = this
let arguments_ = Array.from(arguments)
let arguments1 = arguments_.length && arguments_.slice(1,arguments_.length) || []
return function(){
let arguments2 = Array.from(arguments)
return fn.apply(context,arguments1.concat(arguments2))
}
}