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
| Chrome | 6 |
| Edge | yes |
| Firefox | 4 |
| Internet Explorer | 9 |
| Opera | 12 |
| Safari | 5.1 |
| Android webview | yes |
| Chrome for Android | yes |
| Edge mobile | yes |
| Firefox for Android | 4 |
| Opera Android | yes |
Leave a comment