Created
July 14, 2021 11:26
-
-
Save BorisOsipov/874afc211df4989826b1da49971f2bee to your computer and use it in GitHub Desktop.
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
const mySecretAwareObject = { | |
login: "foo", | |
password: "haha" | |
} | |
Object.defineProperty(mySecretAwareObject, "password", { | |
enumerable: false, | |
value: 'supersecretpassword' | |
}) | |
console.log(mySecretAwareObject) // prints object without password field value | |
console.log(mySecretAwareObject.password) // password is still available via direct access though | |
// output | |
// { login: 'foo' } | |
// supersecret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment