+ 6
assuming you are talking about Javascript, you should mostly use === Array equality is tricky, though... https://flexiple.com/javascript/javascript-array-equality/ https://stackoverflow.com/questions/7837456/how-to-compare-arrays-in-javascript
17th Dec 2022, 11:06 AM
Bob_Li
Bob_Li - avatar
+ 5
In the first comparison, arr1 and arr2 are being compared using the == operator, which compares their values rather than their references. Since arr1 and arr2 are distinct arrays with the same elements, they are considered equal in value, but not equal in reference. Therefore, the comparison evaluates to false. In the second comparison, arr1 and arr3 are also being compared using the == operator. However, in this case arr3 is assigned the value of arr1, so they both refer to the same array in memory. Therefore, the comparison evaluates to true.
17th Dec 2022, 7:03 PM
Sadaam Linux
Sadaam Linux - avatar
+ 3
From what I understood: arr1 == arr3 will return true because arr3 and arr1 points to same object And arr1 == arr2 returns false because they point to different objects (even though both arrays have the same content, still they're different)
17th Dec 2022, 11:37 AM
Roopesh
Roopesh - avatar