Skip to content

Instantly share code, notes, and snippets.

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