Created
September 19, 2013 09:21
-
-
Save adamvr/6621065 to your computer and use it in GitHub Desktop.
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
var augment = function (obj /* args */) { | |
var args = Array.prototype.slice.call(arguments, 1); | |
for (var i = 0; i < args.length; i += 1) { | |
var arg = args[i]; | |
// Skip non-objects | |
if ('object' !== typeof arg) continue; | |
for (var k in arg) { | |
var v = arg[k]; | |
// Skip keys that are already present | |
if (k in obj) continue; | |
obj[k] = v; | |
} | |
} | |
return obj; | |
}; | |
var a = { | |
a: 'b', | |
c: 'd', | |
e: 'f' | |
}; | |
var b = { | |
a: 'dontoverride', | |
f: 'g', | |
h: 'a' | |
} | |
var c = { | |
f: 'dontoverride', | |
e: 'dontoverride' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment