Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const user = {
firstName: 'Akash'
}
// Freezing Object
Object.freeze(user)
console.log(Object.isFrozen(user)) // true
console.log(Object.isSealed(user)) // true
console.log(Object.isExtensible(user)) // false
// Try to update content
user.lastName = 'Rajvanshi'
console.log('lastName' in user) // false
delete user.firstName
console.log('firstName' in user) // true
user.firstName = 'Abha'
console.log(user.firstName) // Akash
const descriptor = Object.getOwnPropertyDescriptor(user, 'firstName')
console.log(descriptor) // { value: 'Akash', writable: false, enumerable: true, configurable: false }
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.