Home >Web Front-end >JS Tutorial >Summary of two methods of writing multiple statements into one statement in js_javascript skills
Summary of two methods of writing multiple statements into one statement in Javascript
1. Use the comma operator to write multiple statements into one statement
1. Declare multiple variables at one time
var i=1,j=1,k=1
2. Separate multiple statements with commas
i=1,j=i 2,k=j 2
2. Use curly braces to separate Multiple statements are written as one statement
If statement, while statement, do/while statement, for statement, for/in statement and function statement can only be followed by one sub-statement. In this case, { and } Surround multiple statements into one statement.