Created
September 8, 2012 11:59
-
-
Save josephj/3674198 to your computer and use it in GitHub Desktop.
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
mods[“ykpsb”] = function () { | |
// 利用闭包与外界隔绝 | |
var privateVar, | |
publicFn; | |
// 内部自行处理,不会影响其他模块 | |
privateVar = "123"; | |
publicFn = function () {}; | |
return { | |
// 仅揭露需公开的方法 | |
publicFn: publicFn | |
}; | |
}(); | |
// 外界仅可存取公开方法 | |
mod["ykpsb"].publicFn(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment