Skip to content

Instantly share code, notes, and snippets.

@ashwinkumar2438
Created June 20, 2021 12:07
Show Gist options
  • Save ashwinkumar2438/fbc7c7e535b537a2d3aaf3149de8aedb to your computer and use it in GitHub Desktop.
Save ashwinkumar2438/fbc7c7e535b537a2d3aaf3149de8aedb to your computer and use it in GitHub Desktop.
class MI{
#secretcode=123;
getAccess(value){
if(value===this.#secretcode)return 'granted access.';
else return 'access denied.'
}
}
let agent=new MI();
agent.#secretcode=0; //@throws Uncaught SyntaxError: Private field '#secretcode' must be declared in an enclosing class.
agent.getAccess(0); //@returns "access denied."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment