I have 2 objects and i want to compare old with new and return the new one if values of object differs. I tryed multiple solutions and it seems i can't achieve this. here is what i've tryed
  var new_pkg ={scooter_id:"TM0060",lat:"45.747646",lng:"21.231496",alt:"99.200"};
    var old_pkg={scooter_id:"TM0060",lat:"25.747746",lng:"31.221496",alt:"100.200"};
    function difference(new_pkg, old_pkg) {
        function changes(new_pkg, old_pkg) {
            return _.transform(new_pkg, function(result, value, key) {
        if (!_.isEqual(value, old_pkg[key])) {
                result[key] = (_.isObject(value) && _.isObject(old_pkg[key])) ? changes(value, old_pkg[key]) : value;
            }
        });
    }
    return changes(new_pkg, old_pkg);
}
i want to return {lat:"45.747646",lng:"21.231496",alt:"99.200"};
 
     
     
     
    