Skip to content

Instantly share code, notes, and snippets.

@cesarkohl
Created January 13, 2020 14:42
Show Gist options
  • Select an option

  • Save cesarkohl/3296932775179af91dc8bb9b34f27117 to your computer and use it in GitHub Desktop.

Select an option

Save cesarkohl/3296932775179af91dc8bb9b34f27117 to your computer and use it in GitHub Desktop.
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