Why is 1===1===1 false?

前端 未结 5 2099
我寻月下人不归
我寻月下人不归 2021-01-01 09:37

In a browser console, entering 1===1 evaluates to true. Entering 1===1===1 evaluates to false.

I assume that this

5条回答
  •  一生所求
    2021-01-01 09:50

    The === operator doesn't just test equality, but also type equality. Since an integer is not a boolean, true === 1 is false.

    Compare:

    true == 1; // true
    true === 1; // false
    

    Example.

提交回复
热议问题