[Solved] How to compare two objects in javascript and get difference?


The solutions is,

function Newdifference(origObj, newObj) {
  function changes(newObj, origObj) {
    let arrayIndexCounter = 0
    return transform(newObj, function (result, value, key) {
      if (value && !isObject(value) && !isEqual(JSON.stringify(value), JSON.stringify(origObj[key]))) {
        let resultKey = isArray(origObj) ? arrayIndexCounter++ : key
        result[resultKey] = (isObject(value) && isObject(origObj[key])) ? changes(value, origObj[key]) : value
      }
    });
  };
  return changes(newObj, origObj);
}

This function will return the changes which are traced in two objects

solved How to compare two objects in javascript and get difference?