Is it guaranteed that `Math.cos(0) === [Math.cos][0](0)`?

Viewed 85

In Javascript it's different to use a.b(c) or [a.b][0](c) the reason being the binding of this to the object a or not during the execution of the code of a.b.

Following the same reasoning using

var z = Math.cos;
console.log(z(1));

could in theory be different from console.log(Math.cos(1)) but doesn't seems so in practice.

The question is: is it guaranteed by the standard that for predefined objects like Math, Symbol or Object the this context is irrelevant in a compliant implementation?

With Math the question seems silly, as apparently there's no reason to depend on the context... however for example for Symbol.for it's reasonable to assume that an implementation could store the global symbol table in an object member and in that case using [Symbol.for][0]("x") wouldn't work.

Symbol.for indeed seems to work fine without context in node, chrome and firefox, but I wonder if this is guaranteed or just incidental...

1 Answers
Related