Limit Changes to a JavaScript object with Object.seal()

May 8, 2020
Or view on egghead.io

In this lesson we’ll learn how to limit the types of changes that can be done to an object in JavaScript using the built in

Object.seal()
method. Once an object has been passed to
Object.seal()
, existing properties can be updated, but no new properties can be added and no properties can be deleted.

This is helpful in a variety of situations, particularly with preventing inadvertent changes to an object’s structure throughout a codebase, while still allowing for updates.

Want more like this? Sign up to get one article delivered weekly by email.
© 2023 Mark Foster