Dev Helpers

JavaScript / Objects

Freeze a configuration

Dev Helpers · August 28, 2025

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 demo

Implementation 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

Related articles

Sum distances with a Euclidean norm

A diagonal is longer than either of its components. Math.hypot combines perpendicular distances without making the caller square each input.

Build an OS-independent path

Path conventions belong to the destination. Use an explicit path flavour when generating portable asset names.

Resolve ranked ties

A leaderboard needs an explicit tie policy. Ranking tied scores and sorting their display order are separate decisions.