C.2. Operators

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 not exactly 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
,Specify multiple expressions in place of one expression. For example, you can use this operator to specify two variables to initialize at the beginning of a for loop:
for (x=0, y=0; x<=20; x++) {
 // loop code
}
deleteDelete specified object
newCreate new object
thisReference current object
typeofType of object (number, string, and so on)
voidEvaluate expression without return value

String Operators

OperatorUse
+Concatenation

Escape Characters

CharactersDescription
\'Single quote
\"Double quote
\\Backslash
\bBackspace
\fForm feed
\nNewline
\rCarriage return
\tTab

The backslash can also be used to escape any character simply by prefixing the character with a backslash.

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.