Skip to content

Instantly share code, notes, and snippets.

@krasimir
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krasimir/9962629 to your computer and use it in GitHub Desktop.
Save krasimir/9962629 to your computer and use it in GitHub Desktop.
Extending
var Base = require('./Base');
module.exports = Base.extend({
});
var Base = require('./Base');
module.exports = Base.extend({
});
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;
}
}
node ./index.js
outputs: 300 10
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