Operators and Loops
JavaScript has both binary and unary operators, and one special ternary operator, the conditional operator. A binary operator requires two operands, one before the operator and one after the operator:
JavaScript has the following types of operators :
-
Assignment operators
An assignment operator assigns a value to its left operand based on the value of its right operand.
-
Comparison operators
A comparison operator compares its operands and returns a logical value based on whether the comparison is true. The operands can be numerical, string, logical, or object values.
-
Arithmetic operators
An arithmetic operator takes numerical values (either literals or variables) as their operands and returns a single numerical value.
-
Bitwise operators
A bitwise operator treats their operands as a set of 32 bits (zeros and ones), rather than as decimal, hexadecimal, or octal numbers.
-
Logical operators
Logical operators are typically used with Boolean (logical) values; when they are, they return a Boolean value. However, the && and operators actually return the value of one of the specified operands, so if these operators are used with non-Boolean values, they may return a non-Boolean value. -
String operators
In addition to the comparison operators, which can be used on string values, the concatenation operator (+) concatenates two string values together, returning another string that is the union of the two operand strings.
-
Conditional (ternary) operator
The conditional operator is the only JavaScript operator that takes three operands. The operator can have one of two values based on a condition.
-
Comma operator
The comma operator (,) evaluates both of its operands and returns the value of the last operand.
-
Unary operators
A unary operation is an operation with only one operand.
-
Relational operators
A relational operator compares its operands and returns a Boolean value based on whether the comparison is true.
for more detail click HERE
Loops (for , while Statement)
-
**FOR Statement
A for loop repeats until a specified condition evaluates to false. A for statement looks as follows:
for ([initialExpression]; [conditionExpression]; [incrementExpression]) statement
-
do…while statement
The do…while statement repeats until a specified condition evaluates to false.
A do…while statement looks as follows:
do
statement
while (condition);
-
while statement
A while statement executes its statements as long as a specified condition evaluates to true.
A while statement looks as follows:
while (condition)
statement
## for more detail click HERE