Objects, Functions, and Classes25% of the exam

Objects: properties, prototypes and descriptors

How object literals, bracket and dot access, copies, the prototype chain and property descriptors behave, so you can pick the object technique a requirement needs and predict what keys, lookups, freeze and seal do.

Official exam objective
Given a business requirement, apply fundamentals of object implementation to solve the business requirement.

~7 min read · 15 practice questions ·

What the exam expects

  • Read and write properties with dot and bracket notation, computed keys, shorthand properties, methods and getters/setters, and predict the result.
  • Merge or copy objects without mutating a shared source, and know that every built-in copy is shallow.
  • Put shared behaviour on a prototype (Object.create, constructor prototype) and predict lookups, shadowing and delete along the prototype chain.
  • Choose Object.freeze, Object.seal, Object.preventExtensions or Object.defineProperty from a mutability requirement, and read property descriptors.
  • Tell own from inherited and enumerable from hidden properties with in, Object.hasOwn, Object.keys/entries and for...in.
  • Key terms: own property (defined on the object itself, not inherited); prototype (the object a failed lookup continues to); property descriptor (a property's value, writable, enumerable, configurable, or get/set); enumerable (shows up in Object.keys and for...in); shallow copy (new outer object, same nested objects).

Key facts

Bracket required
Detail
Names with spaces or hyphens, starting with a digit, or held in a variable
Object as key
Detail
Coerced to the string "[object Object]"
Object comparison
Detail
By reference; distinct objects are never equal
Merge order
Detail
Later sources overwrite earlier ones; the first argument is mutated
Spread copy
Detail
Shallow; skips non-enumerable properties and the prototype
delete and inheritance
Detail
Removes only own properties; the inherited value reappears
in
Detail
Searches the object and its prototype chain
Object.hasOwn
Detail
Own properties only; replaces hasOwnProperty
for...in
Detail
Own and inherited enumerable string keys
defineProperty defaults
Detail
writable, enumerable, configurable default to false when the property is new
Seal
Detail
No add or delete; writable values still change
Freeze
Detail
No add, delete or change; shallow; failed changes usually throw in strict mode and are otherwise ignored silently
Sources for this section (11)
  • Why does a memo cache keyed by two different customer objects end up with one entry?
  • When does `Object.assign` change the shared defaults object?
  • Why do instances share a method defined on `Constructor.prototype` but not one assigned in the constructor?
  • Which check returns true for an own property whose value is `undefined` but false for an inherited one?
  • What does `delete` do when the same name also exists on the prototype?

The questions are free to read. Answers with their sources and self-grading are included with the pack.

Keep reading with the JavaScript Developer pack

  • Core concepts
  • Exam traps
  • Worked scenario

The pack includes:

  • All 24 lessons of the JavaScript Developer guide, with reading progress
  • Interactive decision walks and step-by-step sequence steppers
  • Inline practice questions and one-click topic practice (15 questions for this lesson)
  • An official source cited for every claim
  • An AI tutor that answers from the guide
  • Unlimited timed practice exams

Practice for the JavaScript Developer exam