Object.preventExtensions, seal, and freeze

Learn how Object.freeze and Object.seal are similar to Object.assign and help us implement functional programming. ES2015 adds the ability to truly freeze an object and make it immutable.

In this lesson, we’ll cover three functions that allow us to enforce functional programming. Each of these functions makes our object inflexible to varying degrees. We can prevent property addition, or we can freeze an object entirely.

Object.preventExtensions

Preventing Extensions

This is a function that helps us approach immutability. Once it’s called on an object, we can’t add anything to it.

Deletions and changes are still allowed. Only property addition is forbidden.

Get hands-on with 1000+ tech skills courses.