Freeze, Seal and Property Descriptors
Object.freeze stops all changes, seal stops adding or removing, preventExtensions stops adding. Property descriptors control writable, enumerable and configurable flags.
Example
"use strict";
const a = Object.freeze({ x: 1 });
try { a.x = 2; } catch (e) { console.log(e.name); }
const b = Object.seal({ y: 1 });
b.y = 5;
console.log(b.y, Object.isFrozen(a), Object.isSealed(b));Exercise
Stop all changes.
Object.(obj)
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.