Created
March 27, 2014 06:53
-
-
Save crongro/9801762 to your computer and use it in GitHub Desktop.
모듈단위로 public/private분리하기.
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 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