Skip to content

Instantly share code, notes, and snippets.

@jackz3
Created May 9, 2012 15:02
Show Gist options
  • Save jackz3/2645186 to your computer and use it in GitHub Desktop.
Save jackz3/2645186 to your computer and use it in GitHub Desktop.
var Module = (function() {
// 下面函数是私有的,但可以被公开函数访问
function privateFunc() { … };
// 返回一个对象赋予Module
return {
publicFunc: function() {
privateFunc(); // publicFunc可以直接访问privateFunc
}
};
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment