JavaScript | Object.seal vs Object.freeze

Object.seal()

Object.seal method is used to seal an object which means new properties cannot be added to the object but values of existing properties can be changed as long as they are writable.

Object.seal(<Object name>);
console.log(Object.isSealed(myObj)); // Logs true

Object.freeze()

Object.freeze is used to freeze an object which means new properties cannot be added to the object and existing properties cannot be changed.

console.log(Object.isFrozen(myObj)); // Logs true

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store