Created
December 7, 2014 19:20
-
-
Save jeremyckahn/7ced9aaa7d02af8c84df to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* global console: true */ | |
var module = (function () { | |
function privateFn () { | |
console.log('I am a private function!'); | |
return 8; | |
} | |
var privateVar; | |
return { | |
method1: function () { | |
return privateFn(); | |
} | |
,getPrivateNumber: function () { | |
return privateVar; | |
} | |
,setPrivateNumber: function (value) { | |
if (typeof value !== 'number') { | |
return; | |
} | |
return privateVar = value; | |
} | |
}; | |
} ()); | |
console.log(module.method1()); | |
console.log(module.setPrivateNumber(5)); | |
console.log(module.getPrivateNumber()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment