-
-
Save athiwatp/5a64031fab052b7069e5303768613bb5 to your computer and use it in GitHub Desktop.
A simple extend function for JavaScript
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(base) { | |
| var parts = Array.prototype.slice.call(arguments, 1); | |
| parts.forEach(function (p) { | |
| if (p && typeof (p) === 'object') { | |
| for (var k in p) { | |
| if (p.hasOwnProperty(k)) { | |
| base[k] = p[k]; | |
| } | |
| } | |
| } | |
| }); | |
| return base; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment