// Base.js
var _ = require("underscore");
module.exports = {
name: "base",
extend: function(child) {
return _.extend({}, this, child);
},
run: function(req, res, next) {
}
}
// test.js
function test() {
var childA = BaseController.extend({name: "A", methodA: function(){
console.log("methodA");
}
});
var childB = BaseController.extend({name: "B", methodB: function(){
console.log("methodB");
}
});
console.log(childA.name);
console.log(childB.name);
if (childA.methodB === undefined && childB.methodA === undefined) {
console.log("childA and childB are mutally with different methods");
}
childA.methodA();
childB.methodB();
}
test()
$ node test.js
A
B
childA and childB are mutally with different methods
method A
method B
【 在 XeCycle (据说是小 X) 的大作中提到: 】
: you should not try that
--
修改:saynothing FROM 218.108.104.*
FROM 218.108.104.*