Array of object deep comparison with lodash

You can make use of differenceWith() with an isEqual() comparator, and invoke isEmpty to check if they are equal or not. var isArrayEqual = function(x, y) { return _(x).differenceWith(y, _.isEqual).isEmpty(); }; var result1 = isArrayEqual( [{a:1, b:2}, {c:3, d:4}], [{b:2, a:1}, {d:4, c:3}] ); var result2 = isArrayEqual( [{a:1, b:2, c: 1}, {c:3, d:4}], [{b:2, … Read more

JavaScript/JSON: Get unknown property of an object

if it’s always the first property of message.name, you could do something like: var keys = []; for (var l in message.name) { if (message.name.hasOwnProperty(l)){ keys.push(l); } } //=>first property value should now be in message.name[keys[0]]); // (its label is keys[0]) Edit: nine years after this answer all modern browsers support es20xx, so it’s safe … Read more