Equality of Arrays: JavaScript Challenge | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Equality of Arrays: JavaScript Challenge

/* My challenger and I both answered this one wrong. My understanding is that == means equality, not assignment and not duplication. So why is the answer false, true? */ What is the output? var arr1= [1,2,3]; var arr2= [1,2,3]; var arr3= arr1; console.log(arr1==arr2); console.log(arr1==arr3);

22nd Mar 2022, 1:52 AM
TahitišŸŒCastillo
TahitišŸŒCastillo - avatar
2 Answers
+ 1
TahitišŸŒCastillo Reference matters The references of arr1 and arr2 are not same But references of arr3 and arr1 are same because you have given reference of arr1 to arr3
22nd Mar 2022, 1:56 AM
AĶ¢J
AĶ¢J - avatar
0
AĶ¢J thank you. JavaScript can be so confusing sometimes.
22nd Mar 2022, 2:17 AM
TahitišŸŒCastillo
TahitišŸŒCastillo - avatar