JS: Access Property

By Xah Lee. Date: . Last updated: .

This page shows all the ways to work with properties.

Get Property

Get Property
syntaxnotesuse proto chainwork with symbol key
o[k] yesyes
Reflect.get (o,k) JS: Reflect.get yesyes

[see JS: Symbol Tutorial]

Set Property

Set Property
syntaxnotesuse proto chainwork with symbol key
o[k] = v noyes
Reflect.set (o, k, v) JS: Reflect.set noyes

Delete Property

Delete Property
syntaxnotesuse proto chainwork with symbol key
delete o[k] JS: Delete operator noyes
Reflect. deleteProperty (o,k) JS: Reflect.deleteProperty noyes

Check Property Existence

Check Property Existence
syntaxnotesuse proto chainwork with symbol key
o.hasOwnProperty(k) JS: Object.prototype.hasOwnProperty noyes
k in o
or
Reflect.has (o,k)
[see JS: “in” Operator] [see JS: Reflect.has] yesyes

Loop-Thru Properties

Loop Over Properties or Values
syntaxnotesproto chainenumerable onlyinclude symbol keyinclude string key
for (let k in o) {…} [see JS: for-in Loop] yesyesnoyes
for (let v of iterable) {…} loop thru values of iterable object iterable. [see JS: for-of Loop] N/AN/AN/AN/A

List Properties

JS: List Properties

JS Object Property

  1. Property Overview
  2. Property Key
  3. Dot vs Bracket Notation
  4. Create/Delete Property
  5. Get/Set Property
  6. Property Existence
  7. Access Property
  8. List Properties
  9. Property Attributes
  10. Getter/Setter
  11. Property Descriptor
  12. Symbol
Like it? Help me by telling your friends. Or, Put $5 at patreon.

Or, Buy JavaScript in Depth

If you have a question, put $5 at patreon and message me.

Web Dev Tutorials