3

Possible Duplicate:
How do you determine equality for two JavaScript objects?
Object comparison in JavaScript

Are there any javascript libraries that can help with comparing two objects for equivalence? So if I have something like

var obj1 = {"name":"Jeff", "gender":"M", "arrayprop":[1,2,3] };
var obj2 = {"name":"Jeff", "gender":"M", "arrayprop":[1,2,3] };

And I would like obj1 and obj2 to return "equal" since they have the same properties/values.

Obviously obj1 === obj2 returns false, but I didn't know if there was a function already available I could use that would return true.

4

1 回答 1

7

There is Underscore.js with the function isEqual() : http://underscorejs.org/#isEqual

于 2012-12-07T19:41:06.443 回答