.isFrozen()

THE-Spellchecker's avatar
Published Dec 19, 2023Updated May 15, 2024
Contribute to Docs

The .isFrozen() static method returns true when the given object is frozen, and false if it is not. An object is considered frozen when you cannot add new properties to it, cannot change the existing properties, and cannot delete the existing properties. For example, you can freeze an with the Object.freeze() static method.

Syntax

Object.isFrozen(newObject);
  • newObj: It is the object to be checked for its frozen state.

Example

The following example checks if an object is frozen.

const avgAnnualTemps = {
Sydney: '18.7 celsius',
Reykjavik: '5.3 celsius',
Tokyo: '16.66 celsius',
};
console.log(Object.isFrozen(avgAnnualTemps));
Object.freeze(avgAnnualTemps);
console.log(Object.isFrozen(avgAnnualTemps));

The above example will give the following output:

false
true

All contributors

Contribute to Docs

Learn JavaScript on Codecademy