What is the difference between the `=` and `==` operators and what is `===`? (Single, double, and triple equals)

= is the assignment operator. It sets a variable (the left-hand side) to a value (the right-hand side). The result is the value on the right-hand side.

== is the comparison operator. It will only return true if both values are equivalent after coercing their types to the same type.

=== is a more strict comparison operator often called the identity operator. It will only return true if both the type and value of the operands are the same.

I would check out CodeCademy for a quick intro to JavaScript.

If you prefer to read more, MDN is a great intro as well.

For those concerned about the source of the term “identity operator” jbabey pointed out that JavaScript: The Definitive Guide seems to mention it.

Leave a Comment