{"slug": "javascript-property-behavior-matrix", "title": "JavaScript Property Behavior Matrix", "summary": "A new JavaScript reference document, created by AI in collaboration with a user, provides a comprehensive matrix of how property types—enumerable vs non-enumerable, string vs symbol, and own vs inherited—interact with operators, loops, spread, and Object static methods. The matrix clarifies behaviors such as property access, assignment, deletion, and copying, highlighting distinctions like masking inherited properties and the exclusion of non-enumerable and symbol keys in certain operations.", "body_md": "A comprehensive reference for how JavaScript property types interact with language operators, loops, spread, and Object static methods.\n\nDocument Note:Created by AI (Gemini) in collaboration with the user.\n\n**Enum vs Non-Enum:** Refers to property enumerability (`enumerable: true`\n\nvs`enumerable: false`\n\n),*not*TypeScript`enum`\n\ntypes.**String vs Symbol:** Refers to the property key type (String keys like`\"a\"`\n\nvs Symbol keys like`Symbol(\"a\")`\n\n).**Own vs Inherited:** Properties defined directly on the object instance vs properties inherited through the prototype chain.\n\n— Property value is evaluated. If it's an accessor, its`✓ Accessed`\n\n**Getter** is executed.— Existing own property value is updated (invokes an own`✓ Overwritten`\n\n**Setter** if defined).— Assignment creates a new`⬖ Masked`\n\n**own data property** on`obj`\n\n, masking the prototype (or invokes an inherited**Setter** if defined).`✓ Deleted`\n\n— Own property is removed from the object.[1](https://gist.github.com/starred.atom#user-content-fn-1-bacf6fede3ac5ab18924c7e40bf71080)— Key exists and is detected (`✓ Found`\n\n`true`\n\nreturned by existence check).— Property is included in the output array or loop iteration. For`✓ Included`\n\n`Object.values()`\n\nand`Object.entries()`\n\n, reading the value invokes**Getters** if present.— Value is evaluated (executing`✓ Copied`\n\n**Getters** if present) and assigned as a data property.— Raw descriptor object`✓ Described`\n\n`{ get, set, value, ... }`\n\nis read directly without invoking accessors.— Property is skipped/bypassed (or returns`✗ Ignored`\n\n`false`\n\non existence checks, same as for missing properties).\n\n| Situation / Operation | Own String (Enum) | Own String (Non-Enum) | Own Symbol (Enum) | Own Symbol (Non-Enum) | Inherited String (Enum) | Inherited (Non-Enum or Symbol) |\n|---|---|---|---|---|---|---|\n`val = obj.prop` / `val = obj[prop]` |\n✓ Accessed |\n✓ Accessed |\n✓ Accessed |\n✓ Accessed |\n✓ Accessed |\n✓ Accessed |\n`obj.prop = val` / `obj[prop] = val` |\n✓ Overwritten |\n✓ Overwritten |\n✓ Overwritten |\n✓ Overwritten |\n⬖ Masked |\n⬖ Masked |\n`delete obj.prop` / `delete obj[prop]` |\n✓ Deleted |\n✓ Deleted |\n✓ Deleted |\n✓ Deleted |\n✗ Ignored |\n✗ Ignored |\n`prop in obj` |\n✓ Found |\n✓ Found |\n✓ Found |\n✓ Found |\n✓ Found |\n✓ Found |\n`Object.hasOwn(obj, prop)` / `obj.hasOwnProperty(prop)` |\n✓ Found |\n✓ Found |\n✓ Found |\n✓ Found |\n✗ Ignored |\n✗ Ignored |\n`for (prop in obj)` |\n✓ Included |\n✗ Ignored |\n✗ Ignored |\n✗ Ignored |\n✓ Included |\n✗ Ignored |\n`Object.keys()` / `Object.values()` / `Object.entries()` |\n✓ Included |\n✗ Ignored |\n✗ Ignored |\n✗ Ignored |\n✗ Ignored |\n✗ Ignored |\n`{ ...obj }` |\n✓ Copied |\n✗ Ignored |\n✓ Copied |\n✗ Ignored |\n✗ Ignored |\n✗ Ignored |\n`Object.assign(target, src)` |\n✓ Copied\n|\n✗ Ignored |\n✓ Copied\n|\n✗ Ignored |\n✗ Ignored |\n✗ Ignored |\n`structuredClone(obj)` |\n✓ Copied\n|\n✗ Ignored |\n✗ Ignored |\n✗ Ignored |\n✗ Ignored |\n✗ Ignored |\n`JSON.stringify(obj)` |\n✓ Copied\n|\n✗ Ignored |\n✗ Ignored |\n✗ Ignored |\n✗ Ignored |\n✗ Ignored |\n`Object.getOwnPropertyNames(obj)` |\n✓ Included |\n✓ Included |\n✗ Ignored |\n✗ Ignored |\n✗ Ignored |\n✗ Ignored |\n`Object.getOwnPropertySymbols(obj)` |\n✗ Ignored |\n✗ Ignored |\n✓ Included |\n✓ Included |\n✗ Ignored |\n✗ Ignored |\n`Reflect.ownKeys(obj)` |\n✓ Included |\n✓ Included |\n✓ Included |\n✓ Included |\n✗ Ignored |\n✗ Ignored |\n`Object.getOwnPropertyDescriptor` / `Object.getOwnPropertyDescriptors` |\n✓ Described |\n✓ Described |\n✓ Described |\n✓ Described |\n✗ Ignored |\n✗ Ignored |\n\n## Footnotes\n\n-\n`delete`\n\nOperator Return Values & Mechanics:`delete`\n\nonly affects**own properties**, leaving inherited prototype properties untouched (and returning`true`\n\n). It returns`true`\n\nif an own property was successfully deleted, or if the property never existed in the first place. It returns`false`\n\nin non-strict mode (or throws a`TypeError`\n\nin strict mode) when attempting to delete an**own non-configurable property**.[↩](https://gist.github.com/starred.atom#user-content-fnref-1-bacf6fede3ac5ab18924c7e40bf71080) -\nWhile both copy values (invoking Getters on`Object.assign`\n\nvs. Object Spread (`{ ...obj }`\n\n):`src`\n\n),`Object.assign(target, src)`\n\nassigns values to`target`\n\nvia`target[k] = val`\n\n. Thus, it triggers**Setters** if`target`\n\n(or its prototype chain) already defines a matching setter. Spread (`{ ...src }`\n\n) always defines new**own data properties** on the object literal being constructed, completely bypassing any existing target setters.[↩](https://gist.github.com/starred.atom#user-content-fnref-2-bacf6fede3ac5ab18924c7e40bf71080)[↩](https://gist.github.com/starred.atom#user-content-fnref-2-2-bacf6fede3ac5ab18924c7e40bf71080)2 -\nExecutes Getters on own enumerable string properties and recursively deep-clones values.`structuredClone(obj)`\n\nConstraints:**Throws a** if any property value is a`DataCloneError`\n\n**Function** or**Method**. Symbols, non-enumerable properties, and prototype chains are completely stripped.[↩](https://gist.github.com/starred.atom#user-content-fnref-3-bacf6fede3ac5ab18924c7e40bf71080) -\nExecutes Getters on own enumerable string properties. Automatically`JSON.stringify(obj)`\n\nConstraints:**omits** properties whose value evaluates to a**Function**,** Symbol**, or`undefined`\n\n(when inside objects), or converts them to`null`\n\n(when inside arrays).[↩](https://gist.github.com/starred.atom#user-content-fnref-4-bacf6fede3ac5ab18924c7e40bf71080)", "url": "https://wpnews.pro/news/javascript-property-behavior-matrix", "canonical_source": "https://gist.github.com/maronarius/059fcaa1918ccaab7075962536787f67", "published_at": "2026-08-01 21:09:13+00:00", "updated_at": "2026-08-01 22:28:12.960315+00:00", "lang": "en", "topics": ["developer-tools"], "entities": ["JavaScript", "Gemini"], "alternates": {"html": "https://wpnews.pro/news/javascript-property-behavior-matrix", "markdown": "https://wpnews.pro/news/javascript-property-behavior-matrix.md", "text": "https://wpnews.pro/news/javascript-property-behavior-matrix.txt", "jsonld": "https://wpnews.pro/news/javascript-property-behavior-matrix.jsonld"}}