javascriptでのクラスひな形
ちょっと調べてたけど、素のjavascriptて最近あまり書かないのかな。。?と思いつつサクッと作ることもあるかと思うので。
(function(global) {
// Constructor
function MyModule(name, age) {
this.name = name;
this.age = age;
return this;
}
// Private Method
function debug() {
console.log("this is debug");
}
// Public Method
MyModule.prototype.getName = function() {
debug();
return this.name;
}
MyModule.prototype.getAge = function() {
debug();
return this.age;
}
global.MyModule = MyModule;
})(this);
以上です。