function a() { return 1; }
function b() { return(1); }
I tested the above code in Chrome\'s console, and both returned 1
.
return
is a statement a keyword that starts the return statement, not a function.
As has been mentioned, the extra parentheses affect evaluation order, but are not used to "execute" the function named return
. That is why these lines work without any problems:
return (1);
var a = (1);
They are, in effect, identical to these lines:
return 1;
var a = 1;
The reason return()
throws a syntax error is for the exact reason the following line throws an error (return statement included for comparison):
return(); // SyntaxError: syntax error
var a = (); // SyntaxError: syntax error