Skip to content

Instantly share code, notes, and snippets.

@mikkoh
Created December 12, 2014 15:42
Show Gist options
  • Save mikkoh/af9c50d654825e07819c to your computer and use it in GitHub Desktop.
Save mikkoh/af9c50d654825e07819c to your computer and use it in GitHub Desktop.
JS Private and Public
module.exports = MyClass;
function MyClass() {
var myPrivatVariable = 10;
return {
publicMethod: function() {
console.log( myPrivatVariable );
privateMethod.call( this );
}
};
}
function privateMethod() {
console.log( this );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment