Comment créer un objet immuable dans JavaScript
The Object.freeze() method freezes an object:
that is, prevents new properties from being added to it;
prevents existing properties from being removed;
and prevents existing properties, or their enumerability,
configurability, or writability, from being changed,
it also prevents the prototype from being changed.
The method returns the object in a frozen state.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze
const obj = {
prop: 42
};
Object.freeze(obj);
obj.prop = 33;
// Throws an error in strict mode
console.log(obj.prop);
// expected output: 42
Friendly Fowl