20.3. Calculations and Operators

JavaScript supports the standard operators for numbers and strings. The following tables outline the basic operators available in JavaScript.

JavaScript Arithmetic Operators

OperatorUse
+Addition
-Subtraction
*Multiplication
/Division
%Modulus
++Increment
--Decrement

JavaScript Assignment Operators

OperatorUse
=Assignment
+=Increment assignment
-=Decrement assignment
*=Multiplication assignment
/=Division assignment
%=Modulus assignment

JavaScript Comparison Operators

OperatorUse
==Is equal to
===Exactly equal to — in value and type
!=Is not equal to
>Is greater than
<Is less than
>=Is greater than or equal to
<=Is less than or equal to

JavaScript Logical Operators

OperatorUse
&&And
||Or
!Not

JavaScript Bitwise Operators

OperatorUse
&And
|Or
^Xor
~Not
<<Left shift
>>Right shift
>>>Zero fill right shift

JavaScript Miscellaneous Operators

OperatorUse
.Object/property/method separator
?Condition operator
deleteDelete specified object
newCreate new object
thisReference current object
typeofType of object (number, string, and so on)
voidEvaluate expression without returning a value

String Operators

OperatorUse
+Concatenation

String Tokens

TokenCharacter
\\Backslash
\'Single quote
\"Double quote
\bBackspace
\fForm Feed
\nLine Feed
\rCarriage Return
\tHorizontal Tab
\vVertical Tab

Get Web Standards Programmer's Reference: HTML, CSS, JavaScript®, Perl, Python®, and PHP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.