![]() |
VOOZH | about |
The Object.freeze() method is used to freeze an object. Freezing an object does not allow new properties to be added to the object and prevents removing or altering the existing properties.
Object.freeze() preserves the enumerability, Configurability, writability, and prototype of the object. It returns the passed object and does not create a frozen copy.
Object.freeze(obj)Example 1: In this example, the object "obj2" has been assigned property from object "obj1", and the properties of "obj1" are frozen therefore new properties and values are prevented from being added to "obj2".
Example 2: In this example, the object "obj" has been assigned "prop: function" which has been later deleted since the object "obj wasn't frozen. After that, a new object "o" has been assigned the frozen values of "obj" which prevented it from further updations.
We have a complete list of Javascript Object methods, to check those please go through this JavaScript Object Complete Reference article.