Skip to content

Instantly share code, notes, and snippets.

@raganwald
Forked from ravicious/private_function.js
Last active August 29, 2015 14:22
Show Gist options
  • Save raganwald/18f8c179101cfd93c291 to your computer and use it in GitHub Desktop.
Save raganwald/18f8c179101cfd93c291 to your computer and use it in GitHub Desktop.
let Person = (() = > {
let firstNameProperty = Symbol('firstName'),
lastNameProperty = Symbol('lastName'),
renameMethod = Symbol('rename');
return class Person {
constructor (first, last) {
this[renameMethod](first, last);
}
fullName () {
return this[firstNameProperty] + " " + this[lastNameProperty];
}
[renameMethod] (first, last) {
this[firstNameProperty] = first;
this[lastNameProperty] = last;
return this;
}
};
)();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment