Dev Helpers
← Back

Freeze a public snapshot

Freeze a public snapshot using TypeScript.

Open this example in the interactive library

Source code

type Item = Readonly<{ id: number; label: string }>;
const items: readonly Item[] = [
  { id: 1, label: "one" },
  { id: 2, label: "two" },
];
console.log(Object.isFrozen(Object.freeze([...items])));

Sample output

true