call,apply,bind 等函数的模拟实现
前言
1. call
Function.prototype.call = function(...args){
const context = args[0] || window;
const arg = args.slice(1);
context.fn = this;
const result = context.fn(...arg);
delete context.fn;
return result;
}2. apply
3. bind
4. new
5. clone
6. debounce
7. throttle
Last updated