Get the property of the difference between two objects in javascript

This function will extract all the difference between two objects. It will also works on nested objects. This code uses some lodash functions. (function names that starts with "_.")

function difference(object, base) {
    function changes(object, base) {
        return _.transform(object, function(result, value, key) {
            if (!_.isEqual(value, base[key])) {
                result[key] = (_.isObject(value) && _.isObject(base[key])) ? changes(value, base[key]) : value;
            }
        });
    }
    return changes(object, base);
}

You could filter the keys (assuming same keys) by checking the unequal value.

var obj1 = { prop1: false, prop2: false, prop3: false },
    obj2 = { prop1: false, prop2: true, prop3: false },
    difference = Object.keys(obj1).filter(k => obj1[k] !== obj2[k]);
    
console.log(difference);