Programming with Objects
In this lesson, we will formally start programming with objects. Let's begin!
We'll cover the following...
Objects are fundamental concepts in JavaScript. You can create and setup objects in several ways, as this code snippet illustrates:
// "Manual" setupvar car = new Object();car.manufacturer = "Honda";car.type = "FR-V";// Setup with constructor functionvar Car = function (manuf, type) {this.manufacturer = manuf;this.type = type;}var car1 = new Car("Honda", "FR-V");// Setup with JSONvar car2 = {manufacturer: "Honda",type: "FR-V"};
Each mode of setup results the same object semantically, a car
that has a manufacturer
and a type
...