• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

5.4. Equality Operators

This section describes the JavaScript equality and inequality operators. These are operators that 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 we'll see in Chapter 6, they are most commonly used in things like if statements and for loops, to control the flow of program execution.

5.4.1. Equality (==) and Identity (===)

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.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint