- Each statement sends a unique instruction.
- Each statement should end with a semicolon. It is not required but it is a good practice to keep your code organized.
Theory is great, but we recommend digging deeper!
What Statements Are
It's crucial that you don't mistake statements for expressions. The discussion of expression vs statement usually mentions that statements are lines of code that determine the sequence of actions, while any piece of code, evaluating to a value, can be identified as an expression.
List of Identifiers
|break||Ends a loop command.|
|continue||Ends and restarts a loop command.|
|do ... while||Runs and loops a block of code until a condition is no longer true.|
|for||Loops a block of code until a specified condition is no longer true.|
|for ... in||Specifies the code to execute for every element in a specified object.|
|function||Defines a function.|
|if ... else||Checks a specified condition and executes a block of code if it is true.|
|return||Returns a specified value and exits the current function.|
|switch||Sets multiple conditions and blocks of code.|
|throw||Generates an error.|
|try ... catch||Defines an error handling block of code.|
|var||Declares a new variable.|
|while||Loops a block of code while a specified condition is true.|