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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want to compare 2 arrays, you could use
JSON.stringifyIt will also compare [nested] Objects within the array, or [nested] Arrays within an Array:
In this jsfiddle, I’ve played a bit with the idea