So you cannot use again, you can think like a constant variable, it's set one time then you can not set again.
As a result, I write a function rbind means 're bind'.
It simply run the function first then returns the function which is not changed.
Function.prototype.rbind=function(o){this.bind(o)()// set and callreturnthis;}functionprintThis(){console.log(this);returnthis}constf=printThis.rbind(5).rbind(7);f();// prints 5, 7f.call(9);// prints 9
When you use bind it does not run your function just it sets the data 5,
So,
printThis.bind(5)
set 5 to 'this' then it does not return the exact function becuse it returns prototype undefined.So you cannot use again, you can think like a constant variable, it's set one time then you can not set again.
As a result, I write a function rbind means 're bind'.
It simply run the function first then returns the function which is not changed.
That is interesting, I can check if prototype is undefined, that means function is already bound.
No it doesn't mean that necessarily. Somebody could explicitly set the prototype to undefined for instance.
So if .prototype is already undefined it means that the function cannot be chained, right?