Skip to main content

Command Palette

Search for a command to run...

JS Operators

Updated
2 min readView as Markdown
JS Operators

The operator is a special symbol used to perform operations on operands.

Types of JS Operators

  • Assignment Operator

  • Arithmetic Operator

  • Comparison Operator

  • Logical Operator

Assignment Operator:

The assignment operator (+=) adds the value of variables.

let's see the examples:

  =  Assignment operator        b = 7;      //7

+ =  Addition assignment        b += 9;     //b = b + 9

- =  Subtraction assignment     b -= 5;     // b = b - 5

* =  Multiplication assignment  b *= 4;     //b = b * 4

/ =  Division assignment        b /= 2;     // b = b / 2

Arithmetic Operator:

Arithmetic operators are used to perform arithmetic on numbers.

let's see the examples:


    +     Addition           x + y

    -     Subtraction        x - y

    *     Multiplication     x * y

    /     Division           x / y

    %     Remainder          x % y

    ++    Increment          ++x or x++

    --    Decrement          --x or x--

Comparison Operator

Comparison operators are used to test true or false.

let's see the examples:


    ==     Equal to                   x == y

    !=     Not equal to               x ! = y

    ===    Strick equal to            x = = = y

    !==    Strick not equal to        x ! = = y

    <      Greater than               x > y

    >=     Greater than or equal to   x > = y

    <      Less than                  x < y

    <=     Less than equal to         x <= y

Logical Operator

Logical operators are used to determine the logic between variable and value.

let's see the examples:

    &&   Logical And    x && y

    ||   Logical Or     x || y

    !    Logical Not    ! x

More from this blog