Skip to content

Instantly share code, notes, and snippets.

@piscis
Created February 9, 2012 13:24
Show Gist options
  • Save piscis/1779908 to your computer and use it in GitHub Desktop.
Save piscis/1779908 to your computer and use it in GitHub Desktop.
Prototype inheritance example
var util = require("util");
var A =function() {
// constructor
}
A.prototype.on = function() {
console.log('Call A: ON');
};
var B = function() {
// constructor
}
util.inherits(B,A);
B.prototype.on = function() {
console.log('Call B: ON');
A.prototype.on.call(this);
};
var TestInstance = new B();
TestInstance.on('foo');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment