-
-
Save justinbmeyer/10408375 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
(function(privateThings){ | |
function Private() { | |
this.data = 'is private'; | |
} | |
Private.prototype.somePrivateFunction = function() { | |
this.foo = 'bar'; | |
}; | |
function Public() { | |
privateThings.set(this, new Private()); | |
} | |
Public.prototype.somePublicFunction = function() { | |
var myPrivate = privateThings.get(this); | |
// myPrivate.data === 'is private'; | |
myPrivate.somePrivateFunction.call(this); | |
}; | |
})(new WeakMap()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment