JavaScript: Prevent Adding Property

By Xah Lee. Date: . Last updated: .

What is Extensible?

together, they determine if property can be added, deleted, or value changed.

Warning: parent object may be extensible

Note: if a object is not extensible, but its parent may be, so people can add properties to the parent object, and your object may still get unexpected properties, because of inheritance.

What Objects Are Extensible?

console.log(
  [Object, Array, Function, String, Date, RegExp].every((x) =>
    Object.isExtensible(x)
  ),
);

[see Object Type]

Check If Object is Extensible

Prevent Adding Properties

Prevent Adding/Deleting Properties

Prevent Adding/Deleting/Writing Properties

JavaScript Prevent Change Property

JavaScript Object and Inheritance

BUY
Ξ£JS
JavaScript in Depth

JavaScript in Depth

Basic Syntax

Value Types

Variable

String

Property

Object and Inheritance

Array

Function

Constructor/Class

Iterable 🌟

Misc