Two summary of two ways to write multiple statements into one statement in Javascript
1. Use the comma operator to write multiple statements into one statement
1. Declare multiple variables at once
var i=1,j=1,k=1
2. Multiple statements are separated by commas
i=1,j=i+2,k=j+2
2. Use curly braces to write multiple statements into one statement
After statements such as if statements, while statements, do/while statements, for statements, for/in statements, and function statements, they can only follow one sub-statement. At this time, multiple statements can be surrounded by { and } to turn them into one statement.
1. Use the comma operator to write multiple statements into one statement
1. Declare multiple variables at once
var i=1,j=1,k=1
2. Multiple statements are separated by commas
i=1,j=i+2,k=j+2
2. Use curly braces to write multiple statements into one statement
After statements such as if statements, while statements, do/while statements, for statements, for/in statements, and function statements, they can only follow one sub-statement. At this time, multiple statements can be surrounded by { and } to turn them into one statement.