Own Properties and Object Tools
An object has own properties and may inherit other properties through a prototype. Property descriptors control attributes such as writability and enumerability; different inspection APIs deliberately include different sets of properties.
Ask whether a field belongs to this record itself, whether it is inherited, and whether your chosen inspection method includes it.
Inspect the same record in different ways
A blog record inherits a default category. It owns a title and a hidden bookkeeping field. Does listing its keys show everything that a property read can find? No: reading a property, testing ownership and enumerating visible keys answer different questions.
owns titlecategory: Generalarticle.category follows the prototype link. Object.hasOwn(article, 'category') is false. Object.keys(article) returns only the own enumerable string keys, so it includes title but not the inherited category or non-enumerable internalId. Reflect.ownKeys(article) includes the non-enumerable own key and any own symbol keys. A for...in loop can include inherited enumerable string properties; it is not equivalent to Object.keys.
Attributes are part of a property
When defining a new data property with Object.defineProperty, omitted writable, enumerable and configurable attributes default to false. That differs from a property created by an ordinary object literal. A strict-mode assignment to a non-writable property throws; in non-strict code some failed assignments are silent. Read the descriptor instead of assuming the object ignored you randomly.
Object spread and Object.assign copy enumerable own values into another object; they do not recursively clone a whole graph or preserve every property descriptor. A nested object can remain shared. Object.freeze prevents changes to an object's own property configuration and data values, but is shallow. It does not recursively freeze a nested settings object.
Use the correct boundary
When validating parsed API input, test the data shape deliberately. An inherited property is not necessarily an accepted supplied field. Avoid blindly copying untrusted field names into privileged configuration objects. This lesson's task receives an ordinary JSON record and an array of requested key names; it selects only keys that the record itself owns, preserving falsy values such as false, 0 and the empty string.
Predict and inspect
Change enumerable to true for internalId and compare Object.keys again. Then freeze the outer record and modify a nested object's value in a separate experiment. Explain the distinction between protecting a binding with const, freezing one object, and deep immutability. They are three different guarantees.