I am having two arrays, how can i compare the two arrays at single shot.
var arr1= ["a","b","c"];
var arr2 = ["a","c","d"]
if(arr1 == arr2){
console.log(true);
}else{
console.log(false);
}
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.
Side note for edge cases:
===is often considered slightly broken for this kind of task becauseNaNbehaves unexpectedly:The code above actually logs
falsebecauseNaN !== NaN. In addition,===can’t distinguish+0from-0. To cover both of these cases, you could use a stronger comparison known as “egal” or “is”, which can easily be implemented like so: