-
-
Save krasimir/9962629 to your computer and use it in GitHub Desktop.
Extending
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 Base = require('./Base'); | |
module.exports = Base.extend({ | |
}); |
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 Base = require('./Base'); | |
module.exports = Base.extend({ | |
}); |
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 _ = require("underscore"); | |
module.exports = { | |
prop: 10, | |
extend: function(child) { | |
return _.extend({}, this, child); | |
}, | |
changeProp: function(v) { | |
this.prop = v; | |
}, | |
getProp: function() { | |
return this.prop; | |
} | |
} |
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
node ./index.js | |
outputs: 300 10 |
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 A = require('./A.js'); | |
var B = require('./B.js'); | |
A.changeProp(300); | |
console.log(A.getProp(), B.getProp()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment