FANDOM


Intro to objects

In the Intro to Objects talk-through, Pamela introduces the viewer to the concept of Objects, a method for storing multiple related pieces of information in a single variable.

As an example, Pamela creates a program that displays various information about Winston.  She begins by doing this using variables, as learned in a prior lesson.  She then explains how it's possible to store information in one defined object using properties, which consist of a key and a value.

The syntax for defining an object and its properties is:

var test = {
    item1: "xyz",
    item2: 13,
    item3: false
};

To access a property defined in an object, the user utilizes what's known as "dot notation".  In the above example, to access the value of item1, the user would reference the following in their code, which represents the object name (in this case, "test"), a dot "." and then the key name (in this case, "item1"):

test.item1


☀ All Khan Academy content is available for free at: www.khanacademy.org

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.