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
yesyes
obj?.k
Optional Chaining Operator
yesyes
obj[k]
Dot Notation vs Bracket Notation
yesyes
Reflect.get(obj, k)
Reflect.get
yesyes

Set

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

Delete

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

Check Existence

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

Loop-Thru Properties

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

List Properties

List Properties

JavaScript Property

JS in Depth
XAH  BUY NOW

JS in Depth

JS Obj Ref

DOM


JS in Depth

Basic Syntax

Value Types

Variable

String

Function

Property

Object and Inheritance

Array

Constructor/Class

Iterable 🌟

Misc