简单实现bind方法
Function.prototype.myBind = function () {
// 保存调用栈
const fn = this;
// 第一个参数为新函数的this
const self = arguments[0];
// bind参数
const args = Array.prototype.slice.call(arguments, 1);
// 使用 apply 来改变指向
// return function (){
// fn.apply(self,
原创
2022-04-08 10:49:13 ·
204 阅读 ·
0 评论