Created
December 3, 2013 10:08
-
-
Save yvesvanbroekhoven/7766911 to your computer and use it in GitHub Desktop.
How can I use CommonJS modules to extend eachother or create inheritance? (This is pseudo code)
This file contains 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 ModuleA = require('module-a'); | |
function ModuleAExt() { | |
ModuleA.prototype.change_name = function(name) { | |
this.name = name; | |
}; | |
return ModuleA; | |
} | |
module.exports = ModuleAExt; |
This file contains 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
function ModuleA() { | |
this.name = "module-a"; | |
} | |
module.exports = ModuleA; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment