Object.freeze + Object.seal syntax S1
- Stage: Stage 1
- Status: Active
- ECMAScript edition: —
- Synchronized: Aug 28, 2026
- 中文译文 · Source repository
This proposal introduces syntax for Object.freeze and Object.seal to improve ergonomics and prevent modification through prototype chains. It sketches syntax like {# . #} for freezing and {| . |} for sealing, applicable to object literals, arrays, destructuring patterns, and function parameters. The proposal is at an early stage with sketches and potential extensions, not yet a formal TC39 proposal.
The README below comes from the upstream repository and may contain outdated stage or status metadata. Use the proposal details above as the current source of truth.
Object.freeze and Object.seal syntax
Rationale
Object.freeze and Object.seal are both useful functions, but they aren't particularly ergonomic to use, especially when dealing with deeply nested objects or trying to do complex things like create a superset of a frozen object. Also even frozen objects can be modified via their prototype chain:
To prevent this you can use Object.freeze({ __proto__: null }) or
Object.freeze(Object.assign(Object.create(null), {})) to ensure that frozen
objects cannot be modified via their prototype chain.
In addition, it would be useful to have these syntaxes in other places. It'd be useful to seal a destructuring expression, or freeze function arguments to create immutable bindings.