What are the differences between freeze, seal and preventExtensions?

Object.freeze, Object.seal, and Object.preventExtensions all three methods are from Object in JavaScript. These methods are used to control the access level of an object. They have a few differences. We are going to discuss those in the following section:

Object.freeze():

The Object.freeze() method freezes an object for further use. We will not be able to change a frozen object. Once Object.freeze() is used on an object we will not be able to add a new property to it, we will not able to modify any existing property or even delete a property.

Object.seal():

The Object.seal() method seals an object for further use. Once Object.seal() is used on an object we will not be able to add a new property to it, we will be able to modify any existing property but not delete a property.

Object.preventExtensions():

The Object.preventExtensions() method prevents an object for further extension. Once Object.prevents() is used on an object we will not be able to add a new property to it, but will be able to modify any existing property and will be able to delete a property.

Following the table showing the comparison of above Object.freeze, Object.seal and Object.preventExtensions methods:

CREATEREADUPDATEDELETE
Object.freeze()xxx
Object.seal()xx
Object.preventExtensions()x
Reference: