Last active
December 21, 2015 15:19
-
-
Save jiggliemon/6325666 to your computer and use it in GitHub Desktop.
Turns a list of objects into a prototype chain
This file contains 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 protofy () { | |
var args = Array.prototype.slice.call(arguments) | |
return (function objectify (obj) { | |
obj = args.shift() | |
return args.length ? protofy.x( Object.create( objectify() ), obj ) : obj | |
}()) | |
} | |
protofy.x = function ( one, two, k ) { | |
for (k in two) one[k] = two[k]; return one | |
} | |
console.dir(protofy({one:1},{two:2},{three:3})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment