JavaScript offers a lot of powerful operators, ranging from arithmetic, string, and logical operators to operators for assignment, comparison, and more (see Table 141).
Table 141. JavaScript operator types
Operator  Used for  Example 

Arithmetic  Basic mathematics 

Array  Array manipulation 

Assignment  Assigning values 

Bitwise  Manipulating bits within bytes 

Comparison  Comparing two values 

Increment/Decrement  Adding or subtracting 1 

Logical  Boolean comparison 

String  Concatenation 

Different types of operators take a different number of operands:
Unary operators, such as incrementing
($a++
) or negation ($a
), take a single operand.
Binary operators, which represent the bulk of JavaScript operators (including addition, subtraction, multiplication, and division), take two operands.
There is one ternary operator, which takes
the form x ? y : z
. It’s a terse,
singleline if
statement that
chooses between two expressions, depending on the result of a third
one. This conditional operator takes three operands.
Like PHP, JavaScript utilizes operator precedence, in which some operators in an expression are considered more important than others and are therefore evaluated first. Table 142 lists JavaScript’s operators and their precedences.
Table 142. The precedence of JavaScript operators (high to low)
Operator(s)  Type(s) 

 Parentheses, call, and member 
 Increment/decrement 
 Unary, bitwise, and logical 
 Arithmetic 
 Arithmetic ... 
No credit card required