I want to understand why the bracket around o.methodin the expression
(o.method)()
are ignored and therefore behave identically to o.method(), with the execution context methodreferencing o. I expected it to behave similarly (o.method || true)(), where the execution context inside methodrefers to a global object.
If I evaluate (o.method)it myself , it returns a link to an autonomous function that is not related to any context. Just rewriting it like this:
var a = (o.method); a();
will have a global context as expected. And I just shortened the code by replacing a, and it produced a different result.
source
share