function a() { return 1; }
function b() { return(1); }
I tested the above code in Chrome\'s console, and both returned 1
.
There is huge difference for humans, and zero difference for Javascript engine.
return 1
is a statement declaring that we need to immediately exit the function yielding value of 1.
return(1)
is the same statement disguised as the function call by the idiotic convention that you are not obliged to insert space outside of parentheses in Javascript. If you would use code like this in production system, any maintainer will come to your office with stake and torches, after spending some time trying to decide whether you do really have return()
function somewhere in codebase or just don't know what return
keyword is for.
As many other people have already correctly said, parentheses do nothing except "group" with higher precedence the literal for the number 1
.