Skip to content

Instantly share code, notes, and snippets.

@davidrhyswhite
Last active April 15, 2018 04:23
Show Gist options
  • Save davidrhyswhite/84eb4f0295c402c5546a to your computer and use it in GitHub Desktop.
Save davidrhyswhite/84eb4f0295c402c5546a to your computer and use it in GitHub Desktop.
const privateMethod = Symbol('privateMethod');
export default class Service {
constructor () {
this.say = "Hello";
}
[privateMethod] () {
console.log(this.say);
}
publicMethod () {
this[privateMethod]()
}
}
// Uncaught TypeError: (intermediate value).privateMethod is not a function
new Service().privateMethod()
// Uncaught TypeError: (intermediate value)[Symbol(...)] is not a function
new Service()[Symbol('privateMethod')]();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment