Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
This section describes the JavaScript equality and inequality operators. These operators compare two values to determine whether they are the same or different and return a boolean value (true or false) depending on the result of the comparison. As shown in Chapter 6, they are most commonly used in such structures as if statements and for loops to control the flow of program execution.
The == and === operators check whether two values are the same, using two different definitions of sameness. Both operators accept operands of any type, and both return true if their operands are the same and false if they are different. The === operator is known as the identity operator, and it checks whether its two operands are "identical" using a strict definition of sameness. The == operator is known as the equality operator; it checks whether its two operands are "equal" using a more relaxed definition of sameness that allows type conversions.