JS: All operations on property

By Xah Lee. Date: . Last updated: .

Get

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

Set

syntaxwork with Symbol Key
obj.k = v no
obj[k] = v ✅
Reflect.set ✅

Delete

syntaxwork with Symbol Key
“delete” operator 👎 ✅
Reflect.deleteProperty ✅

Check existence

syntaxuse proto chainwork with Symbol Key
Object.hasOwn no✅
Object.prototype.hasOwnProperty 👎 no✅
“in” operator ✅✅
Reflect.has ✅✅

List properties