js手写一个apply
js手写一个apply
/**
* 手写一个apply方法
* 函数名字为 myApply
* symbol优化
*/
Function.prototype.myApply = function (targetObj, args) {
// symbol优化
let key = Symbol('keys')
targetObj[key] = this
let resus = targetObj[key](...args)
delete targetObj[key]
return resus
}
本文来自博客园,作者:jialiangzai,转载请注明原文链接:https://www.cnblogs.com/zsnhweb/articles/17764779.html

浙公网安备 33010602011771号