What is it about Javascript that lets me use inverted / backwards parentheses in function calls like this? I'm running in a Node console on the CLI; specifically Node version 0.10.25.
function a(){ return 42 } a() // -> 42 a)( // -> 42. WTF? function b(t){ return t } b(4) // -> 4 b)4( // No function evaluation; presumably dangling parentheses b)(4 // -> 4. WTF?
Addendum: This doesn't appear to work in Chrome 33.0.1750.152, Safari 7.0.2, or Firefox 27.01. Is this actually some kind of "feature" of some interpretation of ECMAScript, or a Node peculiarity? If Node is using V8, shouldn't it match up with the Chrome results?
It is possible that the console wraps everything inside an eval statement: what is actually evaluated is maybe eval(a)(). In that case Chrome returns 42 as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With