Operators in JavaScript

As the question appears, What is an Operator?
Let us make a simple example to explain the operators. Let us take a simple expression 4 + 5 is equal to 9. Here 4 and 5 are called operands and ‘+’ is called the operator. JavaScript supports the following types of operators.
Arithmetic Operators
Comparison Operators
Logical (or Relational) Operators
Assignment Operators
Conditional (or ternary) Operators
Lets have a look on all operators one by one.

Example of JavaScript variables

var x = 5;   // assign the value 5 to x
var y = 2;   // assign the value 2 to y
var z = x + y;   // assign the value 7 to z (5 + 2)


JavaScript Arithmetic Operators

Arithmetic operator are basically used to perform arithmetic operations on numbers.

Operator Description
+ Addition
- Subtraction
* Multiplication
** Exponentiation
/ Division
% Modulus (Division Remainder)
++ Increment
-- Decrement

JavaScript Assignment Operators

Assignment operators are used to assign the values to the variables in JavaScript.

Operator Example Same as
= x = y x = y
+= x += y x = x + y
-= x -= y x = x - y
*= x *= y x = x * y
/= x /= y x = x / y
%= x %= y x = x % y
**= x **= y x = x ** y

JavaScript Comparison Operators

Operator Description
== equal to
=== equal value and equal type
!= not equal
!== not equal value or not equal type
> greater than
< less than
>= greater than or equal to
<= less than or equal to
? ternary operator

JavaScript Logical Operators

Operator Description
&& logical and
|| logical or
! logical not







The Best

Comment here

If you have any query, if you want to know something about any of technical course related to computer science field, if you have any suggestion about relevant to uploaded content or if you anything wrong here (any mistake in content) than please contact us. Keep in mind, comment should be according to community guidelines.