Objects

Cards (7)

  • Objects are non primitive data types that store key-value pairs.
  • Properties consist of a key and a value. The key is the name of the property, and the value is the data stored in the property.
  • If the property name (key) of an object has a space in it, you will need to use single or double quotes around the name.
  • There are two ways to access the properties of an object: dot notation (.) and bracket notation ([]), similar to an array.
  • object.property;
    Get the property of an object by dot notation.
  • The second way to access the properties of an object is bracket notation ([]). If the property of the object you are trying to access has a space in its name, you will need to use bracket notation.
  • Get the key "property name" from an object with bracket notation
    objectName["property name"];