Created
March 25, 2016 16:32
-
-
Save davidrhyswhite/f8ed7a561d9fc37dee08 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
var Service = (function () { | |
var Service = function () { | |
this.say = "Hello"; | |
} | |
Service.prototype.publicMethod = function () { | |
privateMethod.call(this); | |
} | |
var privateMethod = function () { | |
console.log(this.say); | |
} | |
return Service; | |
})(); | |
// Uncaught TypeError: (intermediate value).privateMethod is not a function(...) | |
new Service().privateMethod(); | |
// Will successfully call privateMethod internally. | |
new Service().publicMethod(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment