Why false == “false” is false?

前端 未结 4 1194
一个人的身影
一个人的身影 2021-02-15 14:24

I am still learning the basics of javaScript and I don\'t understand why this happens.

Having type coercion false == \"false\"would be converted into:

4条回答
  •  南旧
    南旧 (楼主)
    2021-02-15 14:54

    false == "false" // false
    

    because, the boolean false is converted into 0, so, we compare 0 with "false" and the output is false

提交回复
热议问题