Created
January 13, 2020 14:42
-
-
Save cesarkohl/3296932775179af91dc8bb9b34f27117 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
| var Person = (function () { | |
| var dataPrivate = new WeakMap (); | |
| function Person (name) { | |
| PrivateData.set (this, {name: name}); | |
| } | |
| Person.prototype.getName = function () { | |
| return dataPrivate.get (this) .name; | |
| }; | |
| return Person; | |
| } ()); | |
| var andrew = new Pessoa('Andrew'); | |
| console.log(andrew.getName ()); // Andrew | |
| console.log(andrew.name); // undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment