说我有这样的东西
define(["jquery"], function($) {
return function() {
//public members(use this)
this.publicMember = "I'm a public member";
//private members (use var)
var privateMember = "I'm a priavte member";
//private method
function privateMethod() {
console.log('private function said: ' + privateMember);
};
//privileged method
//can access private variables
this.privilegedMethod = function() {
console.log('privileged function said: ' + this.publicMember + ' and ' + privateMember );
};
};
});
在返回调用者并确保我没有向全局范围公开任何内容之前,如何添加公共方法?
???????.prototype.publicMethod= function () {
console.log('public function said: ' + this.publicMember);
}