Skip to content

Instantly share code, notes, and snippets.

@jiggliemon
Last active December 21, 2015 15:19
Show Gist options
  • Save jiggliemon/6325666 to your computer and use it in GitHub Desktop.
Save jiggliemon/6325666 to your computer and use it in GitHub Desktop.
Turns a list of objects into a prototype chain
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