An assignment operator assigns a value to its left operand based on the value of its right operand. You might be familiar with notation such as “x = x + y”, however as lazy as developers are, we of course have a shorter way of writing such operations.
Compares its operands and returns a boolean based on whether the comparison is true or false.
In order to prevent unexpected behavior, it’s best to always use strict equal.
Takes numerical values as their operands and returns a single numerical value.
Unary operation: an operation with only one operator.
Binary operator: an operation that operates on two operands and manipulates them to return a result.
Logical operators return a boolean value. Besides true and false, there are truthy and falsy values:
Falsy values don’t necessarily have the value false, they simply evaluate to false. There are 6 falsy values:
All truthy values are values that aren’t falsy (that sounds very obvious, but there are too many values that are truthy. It’s much simpler to make sure that the value isn’t in the list of falsy values!).
Precedence and associativity
Now that you know more about operators, imagine the following scenario:
Operators have a certain precedence: operators with a higher precedence get called first, operators with a lower precedence get called last. It can also happen that all operators have the same precedence, in that case the associativity (the order in which the operators get called: either left-to-right or right-to-left) is important.
There is an entire table that describes which operators have the highest precedence, which can be found here.