Last active
February 16, 2017 16:40
-
-
Save fabwu/c10a10aebc906db26192a5e7f4369fcb to your computer and use it in GitHub Desktop.
Javascript Object Pattern
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
function Position(constructor) { | |
var self = { | |
publicProperty: 'publicProperty', | |
publicFuntion1: publicFuntion1, | |
publicFuntion2: publicFuntion2 | |
}; | |
var privateProperty = 'privateProperty'; | |
function publicFuntion1() { | |
return 'publicFuntion1' | |
} | |
function publicFuntion2() { | |
privateFuntion(); | |
console.log(constructor); | |
console.log(self.publicFuntion1()); | |
console.log(self.publicProperty); | |
console.log(privateProperty); | |
} | |
function privateFuntion() { | |
console.log(constructor); | |
console.log('privateFuntion'); | |
console.log(self.publicFuntion1()); | |
console.log(self.publicProperty); | |
console.log(privateProperty); | |
} | |
return self; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment