Reading-Notes


Project maintained by eslamakram Hosted on GitHub Pages — Theme by mattgraham

JavaScript Operators and Expressions

JS Operators :

  1. Assignment operator : Assign values to JavaScript variables
    • Example: x = y
    • In the next table you can see all Assignment Operators that reduce the arithmetic logic by simplifying the logic
  2. comparison operator : Compares its operands and returns a logical value based on whether the comparison is true.
    • Example: Equal (==)
    • In the following table you can see all comparison Operators
  3. Arithmetic operators : takes numerical values (either literals or variables) as their operands and returns a single numerical value. The standard arithmetic operators are addition (+), subtraction (-), multiplication (*), and division (/).
    • All arithmetic operators listed in the following table:
  4. Logical operators: uses Boolean (logical) values; Also returns 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. The logical operators are described in the following table.

Loops and iteration

There are Two different kinds of loops:

  1. FOR Loops : loops through a block of code a number of times
  2. while loops : loops through a block of code while a specified condition is true
for (let step = 0; step < 5; step++) {
  // Runs 5 times, with values of step 0 through 4.
  console.log('Walking east one step');
}
let n = 0;
let x = 0;
while (n < 3) {
  n++;
  x += n;
}