function testBind () {
console.log(this.a)
}
testBind.prototype.myName = 'testBind'
let obj1 = { a: 1 }
Function.prototype.myBind = function(objThis, ...params) {
const thisFn = this;
let funcForBind = function(...secondParams) {
const isNew = this instanceof funcForBind;
const thisArg = isNew ? this : Object(objThis);
return thisFn.call(thisArg, ...params, ...secondParams);
};
funcForBind.prototype = Object.create(thisFn.prototype);
return funcForBind;
};
let bindThis = testBind.bind(obj1)
let myBindThis = testBind.myBind(obj1)
let sonTestBind = new testBind()
console.log(sonTestBind.myName)
let sonTestMyBind = new myBindThis()
console.log(sonTestMyBind.myName)
console