JavaScript: Access Property, List Properties

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 JavaScript: Reflect.getyesyes

〔►see JavaScript: 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 JavaScript: Reflect.setnoyes

Delete Property

Delete Property
syntaxmeaninguse proto chainwork with symbol key
delete o[k] Returns true, even if property does not exist. 〔►see JavaScript: Delete operator noyes
Reflect.deleteProperty (o,k) Returns true, if delete is successful. 〔►see JavaScript: 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 JavaScript: Object.prototype.hasOwnPropertynoyes
k in o
or
Reflect.has (o,k)
true if is own property or in prototype chain. 〔►see JavaScript: Reflect.hasyesyes

Loop-Thru (Enumerate) Properties

Loop Over Properties or Values
syntaxmeaningproto chainenumerable onlyinclude symbol keyinclude string key
for (var k in o) {…} 〔►see JavaScript: for-in Loopyesyesnoyes
for (var v of iterable) {…} loop thru values of iterable object iterable. 〔►see JavaScript: for-of LoopN/AN/AN/AN/A

List Properties

To list properties, convert the object to array.

〔►see JavaScript: Object to Array

JS Object Property Topic

  1. JavaScript: Property Overview
  2. JavaScript: Property Key
  3. JavaScript: Property Dot Notation / Bracket Notation
  4. JavaScript: Create/Delete Property
  5. JavaScript: Get Property, Set Property
  6. JavaScript: Check Property Existence
  7. JavaScript: Access Property, List Properties
  8. JavaScript: Property Attributes
  9. JavaScript: Getter/Setter Properties
  10. JavaScript: Property Descriptor
Like what you read? Buy JavaScript in Depth
or, buy a new keyboard, see Keyboard Reviews.