Object.preventExtensionsintermediate// Prevent new properties from being added
const obj = { a: 1 }
Object.preventExtensions(obj)
obj.b = 2 // silently ignored
Object.keys(obj) // β ['a']Use Object.preventExtensions() to lock an object so no new properties can be added, while still allowing modifications to existing ones.
Object.preventExtensions() only prevents additions to the target object itself. The prototype can still be modified.
Challenge: Understand that preventExtensions does not restrict prototype modifications.