Created
February 19, 2014 09:56
-
-
Save crongro/9089071 to your computer and use it in GitHub Desktop.
private Method 테스트 가능한 모듈패턴예시.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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