Skip to content

Restrict an Object in JavaScript

View on Twitter

💡 In JavaScript, you can restrict the usage of an object in 3 ways:

👉🏼 preventExtensions() — ❌ add new props, ✅ modify and remove existing props
👉🏼 seal() — ❌ add or remove props, ✅ modify existing props
👉🏼 freeze() — ❌ add, remove or modify props

Object Restriction table with add, modify and remove property as rows and default, preventExtensions, seal and freeze functions as columns.
You might also like
Secure Your VPS: Enable Automatic Updates Read tip
Debug Requests Using a Mirror API Read tip
Find DigitalOcean Region With Lowest Ping Read tip