Skip to content

Instantly share code, notes, and snippets.

@shadone
Last active August 29, 2015 14:15
Show Gist options
  • Save shadone/fc3c1ba62d370d636523 to your computer and use it in GitHub Desktop.
Save shadone/fc3c1ba62d370d636523 to your computer and use it in GitHub Desktop.
function Base() {
}
Base.foo = 'foo';
function Derived() {
Base.call(this);
}
Derived.prototype = Object.create(Base.prototype);
// Derived.prototype.constructor = Derived; // {1}
Derived.bar = 'bar';
var d = new Derived();
console.log('(1) keys(d)', Object.keys(d));
console.log('(2) keys(d.constructor) =', Object.keys(d.constructor)); // why no 'bar' ??!!!
// if uncomment {1} then I get 'bar' but do not get 'foo'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment