Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kidker/0f40a43e7b72446e2e4d09279775d8bd to your computer and use it in GitHub Desktop.
Save kidker/0f40a43e7b72446e2e4d09279775d8bd to your computer and use it in GitHub Desktop.
/**
* Overwrites obj1's values with obj2's and adds obj2's if non existent in obj1
* @param obj1
* @param obj2
* @returns obj3 a new object based on obj1 and obj2
*/
function merge_options(obj1,obj2){
var obj3 = {};
for (var attrname in obj1) { obj3[attrname] = obj1[attrname]; }
for (var attrname in obj2) { obj3[attrname] = obj2[attrname]; }
return obj3;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment