reference types
Last updated 2 years ago
Was this helpful?
โฉ โฉ object
an unordered collection of ( : pairs).
properties of another object, known as it's .
any value that is not primitive is an object.
// creating objects {name: value} // object literal new Object() // `new` statement let obj = Object.create(prototype) // specify an object's prototype
synonyms๏ผ "hash", "hashtable", "dictionary", "associated array".
most common things to do with objects๏ผ
objects.
(get/set, / / ) their .
object literal / new / Object.create()
property access expression
dot notation (.) / bracket notation []
optional chaining (?., ?.[]) / optional invocation ?.()
/ / properties
Object.assign() - copies properties from other objects.
mixin
inheritance
prototype
prototype chain
serializing objects - convert/restore object's state to/from string.
.toString() / .toLacaleString() - object -> string.
.valueOf() - object -> primitive (typically a number)
.toJSON() - a method expected by JSON.stringify()
use optional chaining (?., ?.[]) to safely acess object's members.
literal
the import in import.meta is NOT an objectโ๏ธ
JS object is associated array.
JavaScript: The Definitive Guide โฉ Ch. 6 Object
accessor property
event handler can be an .
ExploringJS โฉ
MDN โฉ โฉ
โฉ