JS: Access Property

By Xah Lee. Date: . Last updated: .

This page shows all the ways to work with properties.

Get Property

Get Property
syntaxmeaninguse proto chainwork with symbol key
o[k] Return the value of the property. yesyes
Reflect.get (o,k) Return the value of the property. [see JS: Reflect.get] yesyes

[see JS: Symbol Tutorial]

Set Property

Set Property
syntaxmeaninguse proto chainwork with symbol key
o[k] = v Modify or create a new property for the object. noyes
Reflect.set (o, k, v) Modify or create a new property for the object. [see JS: Reflect.set] noyes

Delete Property

Delete Property
syntaxmeaninguse proto chainwork with symbol key
delete o[k] Returns true, even if property does not exist. [see JS: Delete operator] noyes
Reflect.deleteProperty (o,k) Returns true, if delete is successful. [see JS: Reflect.deleteProperty] noyes

Check Property Existence

Check Property Existence
syntaxmeaninguse proto chainwork with symbol key
o.hasOwnProperty(k) true if the object has the property. [see JS: Object.prototype.hasOwnProperty] noyes
k in o
or
Reflect.has (o,k)
true if is own property or in prototype chain. [see JS: “in” Operator] [see JS: Reflect.has] yesyes

Loop-Thru (Enumerate) Properties

Loop Over Properties or Values
syntaxmeaningproto 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

[see 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. Check Property Existence
  7. Access Property
  8. List Properties
  9. Property Attributes
  10. Getter/Setter
  11. Property Descriptor
  12. Symbol
Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth

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

Web Dev Tutorials

  1. HTML
  2. Visual CSS
  3. JS Basics
  4. JS in Depth
  5. JS Reference
  6. DOM
  7. SVG
  8. JS Misc