In JavaScript operator is a sign that perform a special operation, for example, + is an operator that is used for adding two elements. JavaScript has many types of operators for example, arithmetic, logical and comparison operators.
Arithmetic Operators in JavaScript
+ addition
– subtraction
* multiplication
/ division
% Modulus or remainder
++ Increment
— Decrement
Assignment Operators in JavaScript
= assignment
Logical Operators in JavaScript
! not
&& and
|| or
Concatenation Operator in JavaScript
We can combine text with variables using concatenation operator. The + sign is used for concatenation/Combination
1 2 3 |
let myName = "Sara"; let myAge = 40; console.log("Hello, my name is " + myName + ", and I am " + myAge + " year old."); |
In the above example we have created two variables myName and myAge. We are concatenating text strings like Hello, my name is with the variable myName.
Comparison Operators in JavaScript
== equal to
=== equal to in value and type
!= not equal to
!== not equal and don’t convert
< less than
> greater than
<= less than or equal to
>= greater than or equal to