Propertiesobjects.md - brainchildservices/curriculum GitHub Wiki

Slide1

JavaScript Object Properties

Properties are the most important part of any JavaScript object.

Properties are the values associated with a JavaScript object. A JavaScript object is a collection of unordered properties. Properties can usually be changed, added, and deleted, but some are read only.

Accessing JavaScript Properties

The syntax for accessing the property of an object is:

 objectName.property      // person.age

or

 objectName["property"]   // person["age"]

or

 objectName[expression]   // x = "age"; person[x]

Slide 2

The expression must evaluate to a property name.

Example 1

 person.firstname + " is " + person.age + " years old.";

Example 2

 person["firstname"] + " is " + person["age"] + " years old.";