Social Icons

Pages

Wednesday, November 30, 2016

Introduction to Objects I 6/33

Intro
We have discussed four data types: numbers, strings, booleans and arrays.
In this lesson, we focus on a fifth data type:objects. This data type is a little bit more complex. Objects allow us to represent in code real world things and entities (such as a person or bank account). We do this by storing all relevant information in one place—an object.
How do we create an object? Like declaring a variable, or defining a function, we use var, followed by the name of the object and an equals sign. Each object then:
starts with {
has information inside
ends with };

Instructions
Create an object called bob that has no information inside the brackets.
var bob = Object();

No comments:

Post a Comment