Created
July 11, 2016 13:20
-
-
Save kidker/0f40a43e7b72446e2e4d09279775d8bd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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