Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const user = {
lastName: 'Rajvanshi'
};
Object.defineProperty(user, 'firstName', {
value: 'Akash',
enumerable: false,
configurable: false,
writable: false
})
// Enumerable
console.log('firstName' in user) // true
console.log(user.propertyIsEnumerable('firstName')) // false
// Configurable
delete user.firstName
console.log('firstName' in user) // true
// Writable
user.firstName = 'Abha'
console.log(user.firstName) // Akash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.