Created
June 18, 2013 19:37
-
-
Save oomlaut/5808558 to your computer and use it in GitHub Desktop.
Modify the Object prototype to allow a passed object argument to be merged in.
This file contains 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
// http://stackoverflow.com/questions/171251/how-can-i-merge-properties-of-two-javascript-objects-dynamically | |
Object.prototype.merge = function(mergeFrom){ | |
var newObj = {}; | |
for (var attrname in this) { newObj[attrname] = this[attrname]; } | |
for (var attrname in mergeFrom) { newObj[attrname] = mergeFrom[attrname]; } | |
return newObj; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment