I need to do operations like compare that two number arrays have the same values, or two objects have the same member values. Is there a method that does this for me already (either ECMAScript or jQuery)?
For example, the function should return true that these both are the same:
var a = [1,2,3,4];
var b = [1,2,3,4];
Or with objects, the function should return that these two are the same:
var a = { id: 99, name: "Chris" };
var b = { name: "Chris", id: 99 };
I’m thinking maybe just JSON.stringify(a) === JSON.stringify(b)? Any problem with that?
Try the equiv library by Philippe Rathé. (Unfortunately the main site seems to be down, so I linked to js-test-driver source.)