✨guard against accidental modifications
an object without prototype.
Last updated
Was this helpful?
an object without prototype.
Last updated
Was this helpful?
Was this helpful?
JS ⟩ value ⟩ object ⟩ create ⟩ Object.create() ⟩ pure object
Object.create()
can be used to protect objects from being modified accidentally.
// the object to protect
const _protected = {
data: 'DO NOT CHANGE THIS!',
};
// ⭐ guard against accidental modifications
const inherited = Object.create(_protected);
// ⭐ this modifies `inherited` itself, not the `protected` one.