Object Oriented JavaScript Tutorial

A class name is the name of the constructor.
A constructor 'acts as' a factory function.
No object is created inside the constructor.
this keyword is used in constructor.
When a constructor is called with the new operator, an object is created before the first line of the constructor.
Constructors create a separate copy for each object.

function Car(sColor, iDoors) {
    this.color = sColor;
    this.doors = iDoors;
    this.showColor = function () {
        alert(this.color)
    };
}
var my1 = new Car("red", 4);
var my2 = new Car("blue",3);