Category Archives: Objects creation

We’d like to create one new object “Car” in JavaScript with the same features: property / state: color method: showColor One way to create your own objects in JavaScript instancing from JavaScript Object:

JavaScript

1

2

3

4

5

varoCar=newObject;

oCar.color="red";

oCar.showColor=function(){

alert(this.color);//outputs "red"

};

But so that we have a trouble: we can’t reuse the same structure (states & methods) to generate new oCar objects How… Read More »