JavaScript: Access Property

By Xah Lee. Date: . Last updated: .

This page shows all the ways to work with properties.

Get

syntaxuse proto chainwork with Symbol Key
obj.k
obj?.k
Optional Chaining Operator
obj[k]
Dot Notation vs Bracket Notation
Reflect.get(obj, k)
Reflect.get

Set

syntaxuse proto chainwork with Symbol Key
obj.k = v no
obj[k] = v no
Reflect.set(obj, k, v)
Reflect.set
no

Delete

syntaxuse proto chainwork with Symbol Key
delete obj[k]
Delete operator
no
Reflect.deleteProperty(obj, k)
Reflect.deleteProperty
no

Check Existence

syntaxuse proto chainwork with Symbol Key
obj.hasOwnProperty(k)
Object.prototype.hasOwnProperty
no
k in obj
“in” Operator
Reflect.has(obj, k)
Reflect.has

Enumerate Properties

syntaxuse proto chainEnumerable onlyinclude Symbol Keyinclude string key
for (let k in obj) {}
for-in Loop
no
for (let v of iterable) {}
for-of Loop
N/AN/AN/AN/A

List Properties

List Properties

JavaScript Property

BUY
ΣJS
JavaScript in Depth

JavaScript in Depth

Basic Syntax

Value Types

Variable

String

Property

Object and Inheritance

Array

Function

Constructor/Class

Iterable 🌟

Misc