Created
March 2, 2022 00:04
-
-
Save alecat88/c1f1bd7bdc4f3b2886710001eaff9274 to your computer and use it in GitHub Desktop.
ES12
This file contains 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
// Let's create a class named User. | |
class User { | |
constructor() {} | |
// The private methods can be created by prepending '#' before | |
// the method name. | |
#generateAPIKey() { | |
return "d8cf946093107898cb64963ab34be6b7e22662179a8ea48ca5603f8216748767"; | |
} | |
getAPIKey() { | |
// The private methods can be accessed by using '#' before | |
// the method name. | |
return this.#generateAPIKey(); | |
} | |
} | |
const user = new User(); | |
const userAPIKey = user.getAPIKey(); | |
console.log(userAPIKey); // This will print: d8cf946093107898cb64963ab34be6b7e22662179a8ea48ca5603f8216748767 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment