I have two arrays say a = [1,2,3]
and b=[1,2,3]
if i do (a==b)
it returns false. how to compare two arrays with same values?
a[0]==b[0]
will return true, but how can we compare two arrays instead of 2 same elements inside two different arrays?
function array_compare(a, b)
{
// if lengths are different, arrays aren't equal
if(a.length != b.length)
return false;
for(i = 0; i < a.length; i++)
if(a[i] != b[i])
return false;
return true;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With