On this page
  1. Object & Reflect
  2. Contents
  3. Inspecting & Transforming Objects
  4. Property Descriptors & Immutability
  5. Reflect Meta-Operations

Object & Reflect

Prev: builtins | Up: builtins | Next: Array & Typed Arrays
Rel: Prototype Chain & new Instantiation Flow, Proxy & Well-Known Symbols
Ref: MDN Web Docs — Object
Tags: #public #web #javascript #builtins


Contents


Inspecting & Transforming Objects

const scores = { ada: 98, grace: 95 };

Object.keys(scores);     // ['ada', 'grace']
Object.values(scores);   // [98, 95]
Object.entries(scores);  // [['ada', 98], ['grace', 95]]
Object.hasOwn(scores, "ada"); // true (safer than scores.hasOwnProperty)

const grouped = Object.groupBy([1, 2, 3, 4], (n) => (n % 2 === 0 ? "even" : "odd"));

Property Descriptors & Immutability

Every property carries internal descriptor flags (value, writable, enumerable, configurable, or get/set):

const cfg = Object.freeze({ host: "localhost", port: 8080 });
Object.getOwnPropertyDescriptor(cfg, "port");
// { value: 8080, writable: false, enumerable: true, configurable: false }

Reflect Meta-Operations

Reflect mirrors every Proxy trap as a clean function returning a boolean instead of throwing (Reflect.get, Reflect.set, Reflect.construct, Reflect.ownKeys).

Linked from

Related notes