Thus, there are dozens of questions with this name, however, all the answers that I could find seem to be mentioned by some hacks that work in some specific cases, but are not useful in others. Many of these are related to jQuery or Ajax, but the problem is pure JavaScript, which occurs at a very basic level:
function f() { false || (return true); }
Declaring this function (no execution) throws
Uncaught SyntaxError: Unexpected token return
in Chrome and
SyntaxError: Return statements are only valid inside functions
in Safari. However, this function does not perform:
function f() { false || (a=true); return true; }
Can anyone explain this strange behavior?
source share