4 ms·
Just for some perspective - this problem does also exists in other languages. In JavaScript writing: {a: 7} == {a: 7} Returns false. A common way of checkin
by throwaway4good 6y ago
Just for some perspective - this problem does also exists in other languages.
In JavaScript writing:
{a: 7} == {a: 7}
Returns false.
A common way of checking for object equality is to go JSON.stringify(a) == JSON.stringify(b).
And finally now with Java 16 (or something) we get records which often will be what programmers in this situation would like to use.
- dtech 6y agoThis is a pretty bad comparison, == doesn't check equality for objects in Javascript and doesn't promise to. Similar to how Java's == doesn't.
- cmeacham98 6y agoAccording to MDN it does[1]: > The equality operator (==) checks whether its two operands are equal, returning a Boolean result. Additionally, the ECMAScript spec calls it the "equality operator" (although admittedly it spells out a 14 step list[2] of how to do this). 1: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... 2: https://tc39.es/ecma262/#sec-abstract-equality-comparison https://tc39.es/ecma262/#sec-abstract-equality-comparison