3 ms·
I still get bitten by > [] == [] < false sometimes. And that's with two equal signs, not three!
by ThePadawan 5y ago
I still get bitten by
> [] == []
< false
sometimes. And that's with two equal signs, not three!
- phist_mcgee 5y agoTwo separate references to two separate arrays equaling false? What's the problem?
- ThePadawan 5y agoJS has a very "unique" opinion that that is how that should be interpreted. Given the same input as above: Python says True. Ruby says true. JS says false. And otherwise, JS is quite lenient with not interpreting the input like you describe it when using "==": > [] == 0 < true > [] == false < true
- de_keyboard 5y agoWhen doing functional programming, immutable lists with value comparison are what you want. However with JS, you only get mutable arrays with reference equality out-of-the-box. You can use a library, as others have point out, but then your code gets very noisy.