You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As you can see the this.r ends up retrieving it's value from o.method instead of o itself.
In it's current form Symbol.result can't preserve this, and it would also be very strange if it was a special case method on functions.
One solution is to change the signature of Function.prototype[Symbol.result] methods to match that of Function.prototype.call which is thisArg, ...arguments. So the code from the example would be equivalent to:
Methods will loose their intended
this
value due to Function'sSymbol.result
wrapper which will override thethis
value to the method itself.Ex:
As you can see the
this.r
ends up retrieving it's value fromo.method
instead ofo
itself.In it's current form
Symbol.result
can't preservethis
, and it would also be very strange if it was a special case method on functions.One solution is to change the signature of
Function.prototype[Symbol.result]
methods to match that ofFunction.prototype.call
which isthisArg, ...arguments
. So the code from the example would be equivalent to:The text was updated successfully, but these errors were encountered: