Last active
January 2, 2016 09:59
-
-
Save tancredi/8286556 to your computer and use it in GitHub Desktop.
Quick, stand-alone deep extend implementation
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
| function extend () { | |
| var out = arguments[0], | |
| i, key, obj, val; | |
| for (i = 1; i < arguments.length; i += 1) { | |
| obj = arguments[i]; | |
| for (key in obj) { | |
| if (obj.hasOwnProperty(key)) { | |
| val = obj[key]; | |
| if (val && typeof val === 'object' && !val.length) { | |
| out[key] = extend({}, val); | |
| } else { | |
| out[key] = val; | |
| } | |
| } | |
| } | |
| } | |
| return out; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment