手写 call 函数
Function.prototype.call2 = function(context) {
context = context || global || window;
context.fn = this;
const args = [...arguments].slice(1);
const result = context.fn(...args);
delete context.fn;
return result;
};
var a = {};
var b = {
print: function(content) {
console.log(content);
}
};
b.print.call(a, 12);
b.print.call2(a, 12);