Comparison operators:
1 :: Evaluating Conditions
- IS EQUAL TO (==) > The equality operator (==) checks whether its two operands are equal in value only, returning a Boolean result.
- IS NOT EQUAL TO(!=) > The inequality operator (!=) checks whether its two operands are not equal, returning a Boolean result.
- STRICT EQUAL TO(===)
The strict equality operator (===) checks whether its two operands are equal in value and have the same data types, returning a Boolean result.
- STRICT NOT EQUAL TO (!==)
The strict inequality operator (!==) checks whether its two operands are not equal, returning a Boolean result.
- GREATER THAT (>)
The greater than operator (>) returns true if the left operand is greater than the right operand, and false otherwise.
- LESS THAN (<)
The less than operator (<) returns true if the left operand is less than the right operand, and false otherwise.
- GREATER THAN OR EQUAL TO (>=)
The greater than or equal operator (>=) returns true if the left operand is greater than or equal to the right operand, and false otherwise.
- LESS THAN OR EQUAL TO (<=)
The less than or equal operator (<=) returns true if the left operand is less than or equal to the right operand, and false otherwise
2 :: LOGICAL OPERATORS
- LOGICAL AND (&&)
The logical AND (&&) operator (logical conjunction) for a set of operands is true if and only if all of its operands are true. It is typically used with Boolean (logical) values. When it is, it returns a Boolean value.
-
**LOGICAL OR ( )** > **The logical OR ( ) operator (logical disjunction) for a set of operands is true if and only if one or more of its operands is true. It is typically used with Boolean (logical) values. When it is, it returns a Boolean value.**
- LOGICAL NOT (!)
The logical NOT (!) operator (logical complement, negation) takes truth to falsity and vice versa. It is typically used with Boolean (logical) values.
3:: LOOPS in JS
JavaScript supports different kinds of loops:
- for - loops through a block of code a number of times.
-
while - loops through a block of code while a specified condition is true.
- do/while - The do/while loop is a variant of the while loop. This loop will execute the code block once, before checking if the condition is true, then it will repeat the loop as long as the condition is true.
Syntax:
-
The for loop has the following syntax:
for (statement 1; statement 2; statement 3) { // code block to be executed… }
- Statement 1 is executed (one time) before the execution of the code block.
- Statement 2 defines the condition for executing the code block.
- Statement 3 is executed (every time) after the code block has been executed.
-
The while loop has the following syntax:
while (condition) { // code block to be executed }
- The do/while loop has the following syntax:
do { // code block to be executed } while (condition);