Hacker News new | ask | show | jobs
by yeasayer 3288 days ago
Relying on JS illogical behaviour:

  [] === [] // false
It's more confusing and error prone than other options mentioned in the article.
3 comments

I understand it's popular to heap abuse on any and all JS features, but please don't jump on that bandwagon.

There's nothing whatsoever illogical about two mutable objects that are not identical being reported as unequal, and it's hard to think of any language that has mutable values at all where there isn't an equivalent feature.

I don't think that particular example is illogical. it's basically the same as writing something like

    new String[1] == new String[1]
in Java, which would also be false.
I will just add that even though I disagree with proposition of that article, understanding this JS behavior is key in writing big redux apps, since it is main source of wasted renders optimizations. If you do it wrong, whole app might rerender on smallest changes.