JS: Get Set Modify Property
Get
| syntax | use proto chain | work with Symbol Key |
|---|---|---|
obj.k
| ✅ | no |
obj?.k
Optional Chaining Operator | ✅ | no |
obj[k]
Dot Notation vs Bracket Notation | ✅ | ✅ |
| Reflect.get | ✅ | ✅ |
Set
| syntax | work with Symbol Key |
|---|---|
obj.k = v
| no |
obj[k] = v
| ✅ |
| Reflect.set | ✅ |
Delete
| syntax | work with Symbol Key |
|---|---|
| delete (operator) ❌ | ✅ |
| Reflect.deleteProperty | ✅ |
Check existence
| syntax | use proto chain | work with Symbol Key |
|---|---|---|
| Object.hasOwn | no | ✅ |
| Object.prototype.hasOwnProperty ❌ | no | ✅ |
| in (operator) | ✅ | ✅ |
| Reflect.has | ✅ | ✅ |