Skip to content

Instantly share code, notes, and snippets.

@apipkin
Created October 31, 2013 16:11
Show Gist options
  • Save apipkin/7252397 to your computer and use it in GitHub Desktop.
Save apipkin/7252397 to your computer and use it in GitHub Desktop.
removes mismatches between object a and object b
function removeMismatch (objA, objB) {
var key, val;
for (key in objA) {
val = objA[key];
if (!objB[key] || typeof objA[key] !== typeof objB[key]) {
delete objA[key];
} else {
if (typeof objA[key] === 'object') {
removeMismatch(objA[key], objB[key]);
} else {
if (objA[key] !== objB[key]) {
delete objA[key];
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment