
BY Simmi Kava
JavaScript: Object.freeze() -yields "true"
Object.freeze()
As we already know, Object.freeze() method freezes an object which means, object can no longer be changed, no new properties can be added, existing properties and their values cannot be modified.
In one of our previous blog, we had already explained the CRUD operations on Object.freeze(), Object.seal() and Object.preventExtensions() method. Here is the quick reference.
CRUD Operations - Object - freeze() | seal() | preventExtensions()
Object.freeze(100) === 100 //true
Object.freeze(null) === null //true
Object.freeze() === undefined //true
Object.freeze(undefined) === undefined //true
If we see in the above example, if the argument is not an object
i.e. is number
, null
or undefined
, Object.freeze()
has no impact and does not do anything and always the result of strict comparison
is true
.
Same goes with Object.preventExtensions()
. Let's see the example below:-
Object.preventExtensions(100) === 100 //true
Object.preventExtensions(null) === null //true
Object.preventExtensions() === undefined //true
Object.preventExtensions(undefined) === undefined //true
BY Simmi Kava
![]() | ![]() | ![]() | ![]() |
Like | Comment | Save | Share |
ARCHIVES
2025
2024
2023
2022