JavaScript: Object.preventExtensions

By Xah Lee. Date: . Last updated: .
Object.preventExtensions(obj)
  • Make obj not extensible.
  • Return obj.
  • No error if obj is not a object type.

💡 TIP: use Reflect.preventExtensions instead.

// make an object not extensible
const jj = {};
Object.preventExtensions(jj);
console.log(Object.isExtensible(jj) === false);

JavaScript Prevent Change Property

BUY ΣJS JavaScript in Depth