Open Playground
JS ReferencesLesson #129

JavaScript Operators Reference

Assignment operators assign values to JavaScript variables.

Complete Operators Reference

Revised July 2025

TypeCommon UseExample
AssignmentAssigns values to variablesx = 5
ArithmeticPerforms arithmetic between variablesx = y + 2
ComparisonCompares variablesx > 8
LogicalDefines the logic between variables(x>0 \\x>0)
BitwisePerforms bitwise operatins on 32 bits numbersx = 5 & 1
MiscMiscellaneous operatorsvoid(0)

JavaScript Assignment Operators

Assignment operators assign values to JavaScript variables.

Given that x = 10 and y = 5, the table below explains the assignment operators:

OperName / LinkExampleSame AsResult
=Simplex = yx = yx = 5
+=Addx += yx = x + yx = 15
-=Subtractx -= yx = x - yx = 5
*=Multiplyx *= yx = x * yx = 50
/=Dividex /= yx = x / yx = 2
%=Remainderx %= yx = x % yx = 0
:Colonx: 45x = 45x = 45

Logical Assignment Operators

OperName / LinkExampleResult
&&=ANDtrue &&= 10x = 10
\\=ORfalse \\= 10x = 10
??=Nullishnull ??= 10x = 10
Learn More: > Study our JavaScript Assignment Tutorial.

JavaScript Arithmetic Operators

Arithmetic operators are used to perform arithmetic between variables and/or values.

Given that y = 5, the table below explains the arithmetic operators:

OperName / LinkExampleResults
+Additionx = y + 2y=5, x=7
-Subtractionx = y - 2y=5, x=3
*Multiplicationx=y*2y=5, x=10
/Divisionx = y / 2y=5, x=2.5
Exponentiationx = y 2y=5, x=25
%Remainderx = y % 2y=5, x=1
++Incrementx = y++y=6, x=5
++Incrementx = ++yy=6, x=6
--Decrementx = y--y=4, x=5
--Decrementx = --yy=4, x=4
+Unary Plusx= +yx=5
-Unary Negationx= -yx=-5
Learn More: > Study our > JavaScript Arithmetic Tutorial.

JavaScript String Operators

The + operator, and the += operator can also be used to concatenate (add) strings.

Given that t1 = "Good ", t2 = "Morning", and t3 = "", the table below explains the operators:

OperExamplet1t2t3Try it
+t3 = t1 + t2"Good ""Morning""Good Morning"Try it
+=t1 += t2"Good Morning""Morning"Try it

Learn More: > Study our JavaScript Strings Tutorial.

Javascript Comparison Operators

Comparison operators are used in logical statements to determine equality or difference between variables or values.

Given that x = 5, the table below explains the comparison operators:

OperName / LinkComparingReturns
==Equal tox == 8false
==Equal tox == 5true
===Strict Equalx === "5"false
===Strict Equalx === 5true
!=Not Equalx != 8true
!==Strict not Equalx !== "5"true
!==Strict not Equalx !== 5false
>Greater thanx > 8false
=Greater or Equalx >= 8false

|

Learn More: > Study our JavaScript Comparisons Tutorial.

JavaScript Logical Operators

Logical operators are used to determine the logic between variables or values.

Given that x = 6 and y = 3, the table below explains the logical operators:

OperName / LinkExample
&&AND(x 1)
\\OR(x === 5 \\y === 5)
!NOT!(x === y)
??Nullish Coalescingx ?? y
Learn More: > Study our > JavaScript Logical Tutorial.

JavaScript Bitwise Operators

Bit operators work on 32 bits numbers. Any numeric operand in the operation is converted into a 32 bit number. The result is converted back to a JavaScript number.

OperNameExampleSame asResultDec
&ANDx = 5 & 10101 & 000100011
\ORx = 5 \10101 \000101015
~NOTx = ~ 5~0101101010
^XORx = 5 ^ 10101 ^ 000101004
>>Right Shiftx = 5 >>> 10101 >>> 100102
>>Signed Rightx = 5 >> 10101 >> 100102
Learn More: > Study our JavaScript Bitwise Tutorial.

Miscellaneous JavaScript Operators

Some miscellaneous JavaScript operators are described below.

OperatorName / LinkExample
:Colonage : 45
[ ]Bracket Accessperson["age"]
[ ]Array Literalcars = ["Saab", "Volvo", "BMW"]
{ }Blockcar = {}
{ }Object Literalcar = {type:"Fiat", model:"500"}
?.Optional Chainingx ?. y
...Spread...myArray
( )Grouping( x + y )
( ) ? x : yTernary Conditional(zArrow Function(a, b) => a + b
newConstructornew Date()
deleteDeletedelete person.age
inRelational in"age" in person
instanceofInstance ofx instanceof Array
typeofType oftypeof "John"
voidVoidvoid(0)
yieldYieldyield x
yield*Yieldyield* x