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

前端 未结 5 2161
我寻月下人不归
我寻月下人不归 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:45

    The behaviour that you mentioned is correct.

    Its because === implies matching based on type and value. true === 1 does not match on type, but true == 1 matches based on value.

提交回复
热议问题