Javascript array equal to zero but not itself

后端 未结 4 1590
故里飘歌
故里飘歌 2020-12-11 07:45

I\'ve been playing around with arrays in JavaScript and cannot figure out why this happens:

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-11 08:17

    console.log(0 == [])
    //true 
    

    You are trying to compare object with an integer, so your object is implicitly typecasted to equivalent integer value that is 0

    console.log([] == [])
    //false 
    

    as two objects are never equal

提交回复
热议问题