Created
September 19, 2013 09:21
-
-
Save adamvr/6621065 to your computer and use it in GitHub Desktop.
Revisions
-
Adam Rudd created this gist
Sep 19, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ 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' }