手写call bind apply
作者:
姜酱i | 来源:发表于
2021-07-12 15:50 被阅读0次
手写call bind apply
Function.prototype.myCall = function(o,...args){
let content = (o===null||o===undefined)?window:o
content._fun = this
let result = content._fun(args)
delete content._fun
return result
}
Function.prototype.myBind = function(o){
let content = (o===null||o===undefined)?window:o
content._fun = this
return function(...args){
content._fun(args)
delete content._fun
}()
}
Function.prototype.myApply = function(o,args){
let content = (o===null||o===undefined)?window:o
content._fun = this
let result = content._fun(...args)
delete content._fun
return result
}
本文标题:手写call bind apply
本文链接:https://www.haomeiwen.com/subject/itzrpltx.html
网友评论