How to check if two arrays are equal with JavaScript?

var a = [1, 2, 3];
var b = [3, 2, 1];
var c = new Array(1, 2, 3);

alert(a == b + "|" + b == c);

demo

How can I check these array for equality and get a method which returns true if they are equal?

Does jQuery offer any method for this?

13 thoughts on “How to check if two arrays are equal with JavaScript?”

Leave a Comment