Function.prototype.mybind = function(context, ...args) {
return (...newArgs) => {
return this.call(context, ...args, ...newArgs);
}
}
// 测试用例
let cc = {
name : 'TianTian'
}
function say(something,other){
console.log(`I want to tell ${this.name} ${something}`);
console.log('This is some'+other)
}
let tmp = say.mybind(cc,'happy','you are kute')
let tmp1 = say.bind(cc,'happy','you are kute')
tmp()
tmp1()