Skip to content

Instantly share code, notes, and snippets.

@bobrik
Created October 13, 2011 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bobrik/1284614 to your computer and use it in GitHub Desktop.
Save bobrik/1284614 to your computer and use it in GitHub Desktop.
es5 inheritance
exports.spawn = function(parent, props) {
var key,
defs = {
_parent: { value: parent, enumerable: true }
};
for (key in props) {
if (props.hasOwnProperty(key)) {
defs[key] = {
value : props[key],
enumerable : true
};
}
}
return Object.create(parent, defs);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment