Created
June 20, 2021 12:07
-
-
Save ashwinkumar2438/fbc7c7e535b537a2d3aaf3149de8aedb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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