What is the difference between Object.freeze() and Object.seal() in JavaScript?
a)
Object.freeze()
makes an object immutable, while Object.seal()
prevents new properties from being addedb)
Object.freeze()
allows new properties, while Object.seal()
does notc)
Object.seal()
removes properties, while Object.freeze()
adds propertiesd) They are identical
Answer:
a)
Object.freeze()
makes an object immutable, while Object.seal()
prevents new properties from being addedExplanation:
The Object.freeze()
method makes an object immutable, preventing changes to existing properties or the addition of new properties. The Object.seal()
method prevents new properties from being added, but allows changes to existing properties.