Created
November 16, 2010 12:18
-
-
Save kkaefer/701749 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var util = require('util'); | |
function Parent(arg) { | |
console.log('parent constructor: arg=' + arg); | |
} | |
Parent.prototype.foo = function() { | |
console.log('fooing!'); | |
return this; | |
}; | |
function Child(arg) { | |
console.log('child constructor: arg=' + arg); | |
Child.super_.apply(this, arguments); | |
} | |
util.inherits(Child, Parent); | |
Child.prototype.foo = function() { | |
Child.super_.prototype.foo.apply(this, arguments); | |
console.log('child fooing!'); | |
return this; | |
}; | |
Child.prototype.bar = function() { | |
console.log('baring!'); | |
return this; | |
}; | |
new Child('baz').foo().bar(); | |
// child constructor: arg=baz | |
// parent constructor: arg=baz | |
// fooing! | |
// child fooing! | |
// baring! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment