What Is The Point Of Wrapping Javascript Statements In Parentheses?
I have discovered that wrapping different statements in parentheses will return the last one: (34892,47691876297,2000) => 2000 ('test',73,document.createElement('
Solution 1:
That is the comma operator :)
It lets you evaluate expressions from left to right, returning the last operand's result (which, in your case, isn't stored anywhere, and is perfectly valid).
Reference:
Solution 2:
The most obvious point of this is to allow for multiple expressions in a for loop:
for (let x=3, y=6; x < 10; x++, y++) {...}
^^^^^^^^
That's the comma operator, the same operator that also allows for the examples you provided
return (x, y)
Post a Comment for "What Is The Point Of Wrapping Javascript Statements In Parentheses?"