Function.prototype.es6Call = function (context, ...arg) {
let con = context || window;
con.fn = this;
let res = con.fn(...arg);
delete res;
return res;
};
let a = {
name: 'jack',
getName: function (msg) {
return msg + this.name;
},
};
let b = {
name: 'lily',
};
console.log(a.getName.es6Call(b, 'hi~')); // hi~lily