Skip to content

Instantly share code, notes, and snippets.

@crongro
Created March 27, 2014 06:53
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/9801762 to your computer and use it in GitHub Desktop.
Save crongro/9801762 to your computer and use it in GitHub Desktop.
모듈단위로 public/private분리하기.
var obj = (function() {
//private : 한 놈들.(closure 특성을 활용한 private 생성)
var _name = "jisu",
_aData = [],
_innerFun = function(id,name) {
console.log(id , name);
};
function Pub(id) {
this.id = id;
}
Pub.prototype.getUserInfo = function() {
_innerFun(this.id, _name);
}
//private : 이걸 얻는 방법은 constructor를 반환해야 함.
Pub._reName = function(newName) {
_name = newName;
}
return new Pub(1234);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment