Skip to content

Instantly share code, notes, and snippets.

@BorisOsipov
Created July 14, 2021 11:26
Show Gist options
  • Save BorisOsipov/874afc211df4989826b1da49971f2bee to your computer and use it in GitHub Desktop.
Save BorisOsipov/874afc211df4989826b1da49971f2bee to your computer and use it in GitHub Desktop.
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