Binary Operators
By far the most commonly used operators are binary operators. A binary operator is not an operator that performs actions only on 0’s and 1’s, but rather an operator that has two operands. All the comparison operators are binary operators.
Coercion
Some languages (including JavaScript) sometimes coerce type when working with operands of different types. This means that the data type of one of the operands is changed so that the operator can perform its action. You have seen JavaScript coercing type when we tried to add '2' + 2. The number 2 was coerced to become a string, so the output was '22'. Type coercion can be really useful if you know what you are doing, but it can be quite dangerous in some situations. If you try '2' ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access