Using "single parentheses"
I just answered a question where I advised removing the parentheses around the statement and asked why, which I didn't have an answer to when I realized it didn't throw any errors / warnings. I could only cite bad practice. But maybe I'm missing something ...
I made my own tests:
(print('!')); // Outputs '!'
((print('!!'))); // Outputs '!!'
(1); // No output
(qwerty); // No output
(1==2); // No output
(1=2); // Syntax error
// etc...
Can someone shed some light on what's going on and what "stand-alone parentheses" are?
a source to share
What is the use of "stand-alone parentheses"?
In all senses and purposes it is not used at all.
As for what happens, they are just limiting the expressions; there is nothing special or complicated about them. The reason yours (1=2)
doesn't work is for the same reason why the same thing without parentheses won't work: you can't assign a value ( 2
) to a number ( 1
).
a source to share