Function.prototype.calls = function() {
let context = arguments[0];
context.fn = this;
let args = [];
for (let i = 0, len = arguments.length; i < len; i++) {
console.log(arguments[i]);
args.push(arguments[i]);
}
// 把数组转换为一个伪数组
let res = context.fn({...args});
delete context.fn;
return res;
}
let json = {
name: '23'
}
let fn = function (age) {
// console.log(this.name + '' + age)
}
fn.calls(json, 12);