Skip to content
Advertisements

Object.isSealed()

Why Object.isSealed ?

First of all, Sealing an object means that existing features are not deleted or new features are added. Object.isSealed () is used to check if the object is sealed (If you do not know Object.seal (), click on the link and learn the topic first).

Object.isSealed () takes the object as an argument to be checked and returns a boolean representing whether the object is sealed or not. Returns true if the object is sealed, otherwise false. If an object is not extensible and all properties cannot be configured and therefore cannot be removed , it is sealed.

Object.seal () is used to seal an object. Next, Object.freeze () is used to freeze (similar to sealing). It is also possible to seal an object using Object.defineProperty () to forward it to Object.preventExtensions () and then delete all of its properties.

Syntax:

Object.isSealed( obj )

obj: The object to be checked.


JavaScript Object.isSealed Example

        let myObj = {
            prop1: "true",
            prop2: "codes",
            prop3: ".org"
        };

        
        let control1 = Object.isSealed(myObj);
        console.log(control1)

        Object.seal(myObj);
        let control2 = Object.isSealed(myObj);
        console.log(control2)

output:

false
true


Sources:


Browser Support

Chrome6
Edgeyes
Firefox4
Internet Explorer9
Opera12
Safari5.1
Android webviewyes
Chrome for Androidyes
Edge mobileyes
Firefox for Android4
Opera Androidyes
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: