.isFrozen()
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:
falsetrue
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn JavaScript on Codecademy
- Career path
Full-Stack Engineer
A full-stack engineer can get a project done from start to finish, back-end to front-end.Includes 51 CoursesWith Professional CertificationBeginner Friendly150 hours - Free course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner Friendly15 hours