Operators
JavaScript has the following types of operators:
- Assignment operators
- Comparison operators
- Arithmetic operators
- Bitwise operators
- Logical operators
- String operators
- Conditional (ternary) operator
- Comma operator
- Unary operators
- Relational operators
Loops
Loops offer a quick and easy way to do something repeatedly.
for loop
A for loop repeats until a specified condition evaluates to false. A for loop looks like this:
- for (initialExpression; conditionExpression; incrementExpression){statement}
When a for loop executes, the following occurs:
- The initializing expression is executed
- The condition Expression is evaluated, if the value of condition is false, the for loop terminates
- The statement executes
- The increment expression is executed
- Control returns to step 2
while loop
A while loop executes its statements as long as a specified condition evaluates to true. A while loop looks as follow:
- while (condition){statement}
If the condition becomes false, statement within the loop stops executing and control passes to the statement following the loop. The condition test occurs before statement in the loop is executed. If the condition returns true, statement is executed and the condition is tested again