What is the difference between Object.freeze and Object.seal?

Answer

Both prevent object modification but to different degrees. Object.freeze(obj) is the most restrictive: cannot add properties, cannot remove properties, cannot change property values, and cannot change property descriptors. Property attributes become writable: false, configurable: false. Returns the same object. Shallow only — nested objects are not frozen. For deep freezing, recursively apply. Check: Object.isFrozen(obj). Object.seal(obj) is less restrictive: cannot add new properties, cannot remove existing properties, but CAN change existing property values (if writable). Properties become configurable: false. Check: Object.isSealed(obj). Object.preventExtensions(obj) is the least restrictive: only prevents adding new properties — existing properties can be changed or deleted. Hierarchy: freeze > seal > preventExtensions. Violations silently fail in sloppy mode but throw TypeError in strict mode. None of these prevent modification of nested objects — use Immer.js or deep freeze for deep immutability.