Comment by Rohansi
3 days ago
The function reference is actually evaluated first so your preferred order is actually backwards! Consider this:
foo.bar(x)
The `foo.bar` field has to be retrieved before the function can be called. It does not evaluate `x` first. That is observable with JS proxies, or you can test with code like this:
foo()(bar())
Executing the "." operator isn't the same as executing the function.
JS and many other languages have getters so that's not always true.
But my point is that the reference to the function you are calling is actually its own term that needs to be considered in the order of evaluation.
You can also use the IIFE (immediately invoked function expression) pattern that is/was common in JS as an example:
You can use any valid expression in place of a function name, including anything that causes observable side effects.
A "getter" executed on the "." operator isn't the same as executing the function it returns anyway.