Skip to content

Instantly share code, notes, and snippets.

@TooTallNate
Created August 22, 2011 23:31
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 TooTallNate/1163916 to your computer and use it in GitHub Desktop.
Save TooTallNate/1163916 to your computer and use it in GitHub Desktop.
function Parent () {
this.blah = 'test';
}
function Child () {
}
Child.prototype = new Parent()
var instance = new Child()
console.log(instance.hasOwnProperty('blah'));
// false
function Parent () {
this.blah = 'test';
}
function Child () {
Parent.call(this);
}
Child.prototype = Parent.prototype;
var instance = new Child()
console.log(instance.hasOwnProperty('blah'));
// true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment