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

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

〔➤see JavaScript: Dot Notation vs Bracket Notation for Properties

〔➤see JavaScript: Prototype and Inheritance

〔➤see JavaScript: Symbol Tutorial

List Properties

Properties to Array
syntaxmeaningproto chainenumerable onlyinclude symbol keyinclude string key
Object.keys(o) 〔➤see JavaScript: Object.keysnoyesnoyes
Object. getOwnPropertyNames(o) 〔➤see JavaScript: Object.getOwnPropertyNamesnononoyes
Object. getOwnPropertySymbols(o) (ES2015) 〔➤see JavaScript: Object.getOwnPropertySymbolsnonoyesno
Reflect.ownKeys(o) (ES2015) 〔➤see JavaScript: Reflect.ownKeysnonoyesyes

〔➤see JavaScript: Property Attributes

Loop-Thru (Enumerate) Properties

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

〔➤see JavaScript: Symbol Tutorial

JS Object Property Topic

  1. JavaScript: Property Overview
  2. JavaScript: Property Key
  3. JavaScript: Dot Notation vs Bracket Notation for Properties
  4. JavaScript: Create/Delete Property
  5. JavaScript: Read/Write to Property and Prototype Chain
  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.