Operators In JavaScript

Operators In JavaScript

Arithmetic Operators: (+, -, * , /, %, **)

  • Addition (+)

  • Subtraction (-)

  • Multiplication (*)

  • Division (/)

  • Modulo (%) (remainder)

  • Exponential (**)

Example:

Comparison Operators: (<, >, <=, >=, ==,===, !=, !==)

In Comparison operators, the output should be 'True' or 'False'.

  • Less than (<)

  • Greater Than (>)

  • Less than equals to(<=)

  • Greater than equals to (>=)

  • Double equals (==)

  • Triple equals (===)

  • Not equal (!=)

  • Not equals to equals to (!==)

Example of less than (<) and greater than (>):

Example of less than equals to (<=) and greater than equals to (>=):

  • In Double equals (==) operators check only value but in Triple equals (===) operators check value and data types.

  • Example:

Examples of Not equal (!=) operator and Not equals to equals to (!==) operator.

Assignment Operators: (=, +=, -= , \=, /=, %=, \*=)

  • \= (a=b)

  • += (a=a+b)

  • -= (a=a-b)

  • \= (a=a\b)

  • /= (a=a/b)

  • %= (a=a%b)

  • **= (a=a**b)

Logical Operators: (&&, ||, !)

  • And operator (&&)

  • Or operator (||)

  • Not operator (!)

X && Y -> if both arguments are true then only the result will be true. if one argument is false then the result will be false.

X || Y -> if at least one argument is true then only the result will be true. if both arguments are false then the result will be false.

Ex:

Upcoming Chapter ->Conditional Statements