Skip to content

Instantly share code, notes, and snippets.

@crongro
Created February 19, 2014 09:56
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 crongro/9089071 to your computer and use it in GitHub Desktop.
Save crongro/9089071 to your computer and use it in GitHub Desktop.
private Method 테스트 가능한 모듈패턴예시.
var nigayo = {};
nigayo.obj = (function() {
function pub (name) {this.name = name;}
pub.prototype.getName = function() {
return this.name + pub._priv();
};
pub._priv_1 = function() {
return "priv call";
};
pub._priv_2 = function() {
return "priv call";
};
pub.prototype.execTestMode = function() {
//for(var x in pub) { if(typeof pub[x] === "function" && /^\_.[a-zA-Z_$\d]+$/.test(x)) {
// //console.log("find priv function");
//}
//}
return this.constructor;
}
return pub;
})();
var _x = (new nigayo.obj()).execTestMode();
_x._priv_1() //priv()함수 호출 하는 방법
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment