public
Last active

  • Download Gist
child.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14
var Parent = require('./parent'),
util = require('util');
 
var Child = function() {
this.child = 'child';
};
 
util.inherits(Child, Parent);
 
Child.prototype.A = function() {
console.log('Child#A');
};
 
module.exports = Child;
main.js
JavaScript
1 2 3 4 5
var Child = require('./child');
child = new Child();
 
child.A();
child.C();
parent.js
JavaScript
1 2 3 4 5 6 7 8 9
var Parent = function() {};
 
Parent.prototype = {
C: function() {
console.log('Parent#C');
}
};
 
module.exports = Parent;

Running:

$ git clone https://gist.github.com/4704412.git && cd 4704412
$ node main.js

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.