Javascript array equal to zero but not itself

后端 未结 4 1585
故里飘歌
故里飘歌 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:02

    This question is handled with the knowledge of object reference and type conversion more properly.First,in javascript, object value is stored by reference.So we can tell it is different from [] and [],because the two array correspond with two different addr in memory.Second, '==' is a not rigorous operation for both left and right, [] and 0 are both transformed to false.

提交回复
热议问题