Guest User

Untitled

a guest
Oct 20th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. function overrideObject(objOld, objNew) {
  2.  
  3. var objCurrent = Object.assign({}, objOld);
  4.  
  5. for (var i in objOld) {
  6. if (typeof objNew[i] === 'undefined')
  7. continue;
  8. else if (typeof objCurrent[i] === 'object' && typeof objNew[i] === 'object')
  9. objCurrent[i] = overrideObject(objCurrent[i], objNew[i]);
  10. else
  11. objCurrent[i] = objNew[i];
  12. }
  13. return objCurrent;
  14. }
Add Comment
Please, Sign In to add comment