Created
July 23, 2012 04:50
-
-
Save gkatsev/3162008 to your computer and use it in GitHub Desktop.
A simple and naive 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(obj, extend){ | |
var p; | |
for (p in extend) { | |
obj[p] = extend[p]; | |
} | |
return obj; | |
} | |
var obj = { | |
a : 1 | |
, b : 2 | |
, c : 3 | |
} | |
var ext = { | |
a : 4 | |
, b : 5 | |
} | |
extend(obj, ext) | |
// { a: 4, b: 5, c: 3 } | |
obj = extend(obj, ext) | |
// { a: 4, b: 5, c: 3 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment