What is the difference between freeze and seal in JavaScript? Last Updated : 25 Jun, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report In JavaScript, Object.freeze makes an object immutable, preventing any changes to existing properties and values. Object.seal allows changes to existing properties but prevents adding or removing properties. Both methods enforce strict immutability, but freeze is stricter than seal. Table of Content Object.seal()Object.freeze() Differences in a tabular formObject.seal()Object.seal() is another method in JavaScript that prevents new properties from being added to an object and marks all existing properties as non-configurable Unlike Object.freeze(), Object.seal() allows the values of properties to be changed if they are writable. However, it prevents the addition or deletion of properties. Syntax:Object.seal(objectname);Example: To demonstrate creating a non-extensible object using Object. seal() that does not prevent the value of the object from being changed. javascript // creates an object let obj = { // assigns 10 to value value: 10 }; // creates a non-extensible object Object.seal(obj); // the value gets updated to 20 obj.value = 20; console.log(obj.value); Output20 Object.freeze() Object.freeze() is a method in JavaScript that prevents modification of existing property attributes and values of an object. When applied to an object, Object.freeze() makes its properties immutable, meaning they cannot be added, removed, or modified. Attempts to change the object or any of its properties (such as assigning new values or deleting properties) will fail silently or throw an error in strict mode. Syntax:Object.freeze(obj)Example: This example, depicts how Object.freeze() is used to create a non-extensible object, but where the existing value of the object is prevented from being changed and 10 is given as the output. javascript let obj = { // assigns 10 to value value: 10 }; // creates a non-extensible object Object.freeze(obj); // updates the value obj.value = 20; // but cannot change the existing value console.log(obj.value); Output10 Differences in a tabular formfreeze seal It is used to prevent the object from adding new propertiesIt is used to make the properties of an object non-configurable.It is also used so that the current existing properties should not be modifiedIt is also used so that the new properties do not get addedIt takes a parameter as an objectIt takes parameters as an objectIts return type is of the object type.Its return type is e-sealed object type. Comment More infoAdvertise with us Next Article Difference between var and let in JavaScript A ankit0812 Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Misc JavaScript-Questions Similar Reads What is the difference between call and apply in JavaScript ? JavaScript call() Method: It calls the method, taking the owner object as an argument. The keyword this refers to the 'owner' of the function or the object it belongs to. We can call a method that can be used on different objects. Syntax: object.objectMethod.call( objectInstance, arguments ) JavaScr 2 min read Difference between Object.freeze() and const in JavaScript ES6 has brought several new features and methods into JavaScript since its release. Amongst these new features are Object.freeze() method and const. Sometimes people get confused between Object.freeze() method and const but the Object.freeze() and const are completely different. In this article we w 3 min read Difference between var and let in JavaScript In the early days of JavaScript, there was only one way of declaring variables and that was using the var keyword. A variable declared with var is defined throughout the program. One of the issues with using the var keyword was redeclaring a variable inside a block will also redeclare the variable o 3 min read What is the difference between await and yield keywords in JavaScript ? In this article, we will see how Await keyword is different from Yield keywords. Generator Functions: Functions that can return multiple values at different time interval as per the user demands, and can manage its internal state are generator functions. A function becomes a Generator function if it 3 min read Difference Between label and break in JavaScript The labels and the break statement are used within loops and control flow structures to enhance flexibility and manageability. Each serves distinct purposes and can be applied in the various scenarios based on the needs of the code.These are the following topics that we are going to discuss:Table of 3 min read Understanding the Difference between Pure and Impure Functions in JavaScript In this article, we will see the concepts of pure and impure functions in JavaScript, along with understanding their differences, & basic implementation for a better understanding of the concepts. Pure Functions: This function always returns the same output as given the same input parameters. Pu 4 min read Like