Skip to content

Instantly share code, notes, and snippets.

@matthieu-D
Last active May 24, 2017 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthieu-D/651a489b245481485e64d93d1e450e25 to your computer and use it in GitHub Desktop.
Save matthieu-D/651a489b245481485e64d93d1e450e25 to your computer and use it in GitHub Desktop.
var Person = (function() {
var ageSymbol = Symbol('age');
function Person(age) {
this[ageSymbol] = age;
}
Person.prototype.getAge = function(){
return this[ageSymbol];
}
return Person;
}());
var a = new Person(26);
console.log(a.getAge());//Output: 26
a.age = null;
console.log(a.getAge());//Output: 26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment