reading-notes

Code Fellows courses Notes

This project is maintained by QamarAlkhatib

based on what I’ve learned for Javascript Operators and Loops

Operators

In JS we have 10 types of Operators, and I will discuss them as follows:

1. Assignment Operators

and the simplest one is the “ = “ and in JS we assign a value for a variable. this value could be a number, String, another variable, calculation, and so on.

Here is some Example:

2. Comparison Operators

This type of Operators is compares operands and returns the logical value based on whether the Comparison is true, the type od operands could be a numbers, String, logical, and objects values. we use some notation as ( ==, != === , !== , > , >= , <, <=)

Here is some Example

3. Arithmetic Operators

and it takes numerical values as operands and then returnsa single numerical value. and in this Arithmetic we use (addition, subtraction, multiplication, and division) as a stander Operators.

here is some Example:

4. Bitwise Operators

This Operator treats their operandsas a set of 32 bits (Zeros and ones) and not as decimal or hex or even octal numbers.

here is some Example

5. Logical Operators it’s typically used with boolean values and returns the value according to the Operators used. so if the Operator used is a boolean it will return a boolean value, otherwise it will return a non-boolean value. we use (&& and ||) Operators.

here is an Example:

6. String Operators we use the cancatenation Operator (+) and by it we can cancatenates two string values together.

here is some Example:

7. Conditional Operator

The only JavaScript operator that takes three operands is the conditional operator. Based on a condition, the operator can have one of two values. The syntax is as follows:

8. Comma operator (,) returns the value of the final operand after evaluating both operands. This operator is most commonly used inside a for loop to update many variables each time the loop is run.

here is an Example:

for(var i = 0, j = 1; i <= j; i++, j--)

and we have other types such as typeof , and unary Operators.

Loops

Loops are a convenient and efficient technique to repeat a task. Loops come in a variety of shapes and sizes, but they all perform the same thing: they repeat an activity a certain number of times.

here is its syntax:

for ([initialExperssion]; [conditionExperssion]; [incrementExperssion])

statement

here is its syntax:

To go back to the main page, Click here