Created
July 10, 2011 22:32
-
-
Save jimjeffers/1075047 to your computer and use it in GitHub Desktop.
Merge one or more objects.
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
| # Usage: mergeObjects(obj1,obj2,obj3,etc) | |
| mergeObjects = (objects...) -> | |
| combinedObject = {} | |
| for object in objects | |
| combinedObject[key] = value for key,value of object | |
| combinedObject |
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
| mergeObjects = function() { | |
| var combinedObject, key, object, objects, value, _i, _len; | |
| objects = 1 <= arguments.length ? __slice.call(arguments, 0) : []; | |
| combinedObject = {}; | |
| for (_i = 0, _len = objects.length; _i < _len; _i++) { | |
| object = objects[_i]; | |
| for (key in object) { | |
| value = object[key]; | |
| combinedObject[key] = value; | |
| } | |
| } | |
| return combinedObject; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment