BY Simmi Kava14 May 2021 Edit
CRUD Operations: Object - freeze() | seal() | preventExtensions()

JavaScript: Create | Read | Update | Delete Operations - freeze(), seal(), preventExtensions()


Object.freeze():-

This method freezes the object which means new properties cannot be added, existing properties cannot be removed or modified. The enumerability, configurability or writability of existing properties is prohibited. It returns the same object (does not create a copy) that was passed into the function. Also, the frozen object is immutable (not necessarily constant).

Syntax

Object.freeze(obj)

Have you heard about Shallow Freeze? When you call the method Object.freeze() on an object, the freeze rules are applicable only to the immediate properties of object which implies if the values of these properties are object themselves those objects are not bound by any rules and are not frozen.

Object.seal():-

This method seals the object which means it allows to change existing properties but new properties cannot be added to it. Also, all existing properties are marked as non-configurable. But it does not prevent the value of data properties from being changed. The __proto__ property is sealed too.

Syntax

Object.seal(obj)

Object.preventExtensions():-

This method makes the object non-extensible i.e. new properties can never be added to an object. This process is irreversible i.e. if an object is marked as non-extensible, it cannot be reversed. However, properties can still be added to the object prototype.

Syntax

Object.preventExtensions(obj)

Happy Learning!

BY Simmi Kava
LikeCommentSave
LikeCommentSaveShare
0
Categories
General
YantraJS
Developer Guides
Tutorials
Web Atoms Updates

POPULAR POSTS
17 Mar 2021
LATEST ACTIVITY
Simmi Kava
commented this post.
Simmi Kava
liked this post.
Show more
ARCHIVES
2025
2024
2023
2022
TAGS
javascript (56)
developer (25)
javascriptdeveloper (16)
Xamarin.Forms (16)
Html (14)
typescript (12)
webatoms (12)
xamarin (11)
coding (10)
web-atoms (10)
arrays (9)
android (8)
javascript-developer (8)
csharp (7)
dotnet (7)
css (6)
update (6)
dotnet-standard (5)
function (5)
iOS (5)
methods (4)




Web Atoms: JSX (TSX + TypeScript) for Xamarin.Forms, Hot Reload Your App in Production Environment

PlaygroundSamples Repository