Data properties

Object.defineProperties(user, {
  name: { value: "John", writable: false },
  surname: { value: "Smith", writable: false },
  // ...
});

Besides a value, have three special attributes (so-called "flags").

  • Writable -- if true, can be changed, otherwise it's read-only.
  • Enumerable -- if true, then listed in loops, otherwise not listed.
  • Configurable -- if true, the property can be deleted and these attributes can be modified, otherwise not.

Syntax

Let descriptor = Object.getOwnPropertyDescriptor(obj, propertyName);

Syntax

Object.defineProperties(obj, {
  prop1: descriptor1,
  prop2: descriptor2
  // ...
});

Data properties — Structure map

Clickable & Draggable!

Data properties — Related pages: