JavaScript Tutorial #05 Operators

Posted at: May 9, 2019 3:49 PM

In this lesson we will learn about operators in JavaScript.

An operator is a special type of symbols that performing specific types of operations. Like as 5 + 6 * 10 = 65 here is + and * is operators and 5, 6 and 10 is operands.

In JavaScript supports following types of operators.

  • Arithmetic Operators
  • Assignment Operators
  • Comparison Operators
  • Logical Operators
  • Bitwise Operators
  • String Operators
  • Conditional (ternary) Operators

Arithmetic Operators

JavaScript support following arithmetic operators

%modulo (returns the remainder)
++increment (can be prefix or postfix)
--decrement (can be prefix or postfix)


Assignment Operators

Assignment operator is used to assign a value to a variable.

+=add and assign
-+subtract and assign
*=multiply and assign
/=divide and assign
%=modulo and assign


Comparison Operators

A comparison operators compare the operands with comparison operators and return logical value based on comparison is true.

!=not equal
>greater than
>=greater than or equal to
<less than
<=less than or equal to
===identical (equal and of same type)
!==not identical


Logical Operators

Logical operators used with boolean values. More than one relation can be logically joined using logical operators.

&&Logical AND
||Logical OR
!Logical NOT


Bitwise Operators

JavaScript support following binary bitwise operators.

<<shift left (zero fill at right)
>>shift right

In Bitwise opertators converts operands in 32 bits numbers and work with bit by bit. For example the number of 5 and 6 have the binary represatation of 0101 and 0110.


String Operators

Using string opertators concatenate the string.

+=concatenate and assign


Conditional (ternary) Operators

The conditional operator creates an expression that evaluates as one of two expressions depending on a condition.

conditions ? value1 : value2


You can watch video on JavaScript Tutorial #05 Operators

javascript ternary operator javascript logical operators assignment operators conditional operators Bitwise Operators Comparison Operators Arithmetic Operators String Operators

Please leave comments


Angular Templates

React Templates

Magento 2 Templates

truecodex launched free android app. You can download and install truecodex app on your mobile and get notification of the latest post.

Video Tutorials on YouTube