Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
const user = {
firstName: 'Akash'
// Sealing Object
console.log(Object.isSealed(user)) // true
// Configurable == false ( we can't add or delete properties )
const descriptor = Object.getOwnPropertyDescriptor(user, 'firstName')
console.log(descriptor.configurable) // false
console.log(Object.isExtensible(user)) // false
user.lastName = 'Rajvanshi'
console.log('lastName' in user) // false
delete user.firstName
console.log('firstName' in user) // true
// Only we can do is write existing properties
user.firstName = 'Abha';
console.log(user.firstName) // Abha
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.