Answer the question
In order to leave comments, you need to log in
Why does it output false when comparing two identical arrays?
For example:
var arr1 = [1,2,3];
var arr2 = [1,2,3];
console.log( arr1 == arr2 ); //Displays false I
just started learning js, I was interested in this moment.
Answer the question
In order to leave comments, you need to log in
You are comparing references to array objects, and they are different.
Compare for example:
var a = "123";
var b = "123";
console.log(a == b);
var c = new String("123");
var d = new String("123");
console.log(c == d);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question