Freezing a settings object locks its own properties. A referenced nested array or object can still change.
Worked example
const config = Object.freeze({ mode: "demo" });
console.log(Object.isFrozen(config), config.mode);Result
true demoImplementation notes
A configuration tree with mutable descendants needs a deliberate policy for each nested object. Freezing just the parent is useful when replacing a top-level option is the only forbidden operation.
Try it yourself
Freeze a settings object containing an array and try changing each level separately.
Open the JavaScript example →Editorial date August 28, 2025 · Published December 6, 2026