3 ms·
Two separate references to two separate arrays equaling false? What's the problem?
by phist_mcgee 5y ago
Two 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.