Object.freeze allows us to disable object mutation.
Object.freeze
let movie1 = { name: 'Star Wars', episode: 7 }; let movie2 = Object.freeze(Object.assign({}, movie1)); movie2.episode = 8; // fails silently in non-strict mode, // throws error in strict mode console.log(movie1.episode); // writes 7 console.log(movie2.episode); // writes 7
Last updated 3 years ago