Like Us Like Us Facebook Subscribe Subscribe us YouTube Whatsapp Share us Whatsapp Query Send your queries

JavaScript Operators Tutorial with Working Example

JavaScript Operators Tutorial with Working Example

JavaScript operators are used to assign values, compare values, perform arithmetic operations like addition,
multiplication,division, substractions and many more.

In this tutorial we are going learn JavaScript Operators and how to use them in programme.

JavaScript Arithmetic Operators

Arithmetic operators are used to perform arithmetic operation.

Operator Sign/Symbol Example
Addition + x=4+2+2; Result x=8
Subtraction x=4-2-2; Result x=0
Multiplication * x=4*2*2; Result x=16
Division / x=4/2; Result x=2
Modulus or
Division Remainder
% x=15%2; Result x=1
Increment ++ x=5;x=x++; Result x=6
Decrement x=5;x=x–; Result x=4

JavaScript Assignment Operators

Assignment operators assign values to JavaScript variables and constant.

Operator Example Reference
= 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

The addition assignment operator += adds a value to a variable just  like .= in PHP

JavaScript Logical Operators

Logical Operators adds logic in aProgram.

Operator Reference
&& Logical and
! Logical not
|| Logical or

JavaScript Comparison Operators

Comparison Operators used for comparing data or values.

Operator Reference
== equal to
=== equal value and equal type (rarely used)
!= not equal
!== not equal value or not equal type (rarely used)
> greater than
>= greater than or equal to
< less than
<= less than or equal to
? ternary operator
0 0 votes
Article Rating
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Do you have any Query / Suggestion