Currently, I am utilizing Lodash _.isEqual for performing a deep comparison between a local JavaScript object and another JavaScript object fetched through angular $get.
The initial code indicates that the objects are not the same:
$get({...}, function (data) {
cleanupAngularProps(data);
if (_.isEqual(data, {name: 'Someone'}) {
...
}
});
However, after making a slight adjustment, the code now recognizes them as equal (as expected):
$get({...}, function (data) {
cleanupAngularProps(data);
if (_.isEqual(JSON.parse(JSON.stringify(data)), {name: 'Someone'}) {
...
}
});
Upon debugging into the Lodash code, it appears to be failing due to the different constructors in both objects.
Is there a way to resolve this issue without having to clone the data?