3 ms·
The comma operator takes two expressions, evaluates them both, and returns the second. In this case, (1, eval) becomes a reference to the eval function and then
by bulatb 14y ago
The comma operator takes two expressions, evaluates them both, and returns the second. In this case, (1, eval) becomes a reference to the eval function and then gets fed 'this'. Since the call is now indirect, the eval happens in the global scope where 'this' is guaranteed to be the global object.
It's kind of crazy. Details here: http://tinyurl.com/3mzf89r http://tinyurl.com/3mzf89r
The right side is needed for ES5 strict mode, where `this` does not become the global object in a function that wasn't called with `new`, call(), or apply(). In that case the left side will be something falsy and the right side will take over. Details here: http://tinyurl.com/cwbxvxh http://tinyurl.com/cwbxvxh
- eric_the_read 14y agoThanks! I knew what the comma operator was doing, but had no idea why.