How to Add Properties to Objects in Your HTML5 Game
One of the most interesting things about HTML game objects is that they are variables that can contain other variables. When a variable exists in the context of an object, the variable is called a property. Properties are the characteristics of an object, such as its speed or its size. As an example, please look at the following variation of the critter code:
A property is simply a special variable associated with an object. Normally, you use object.property to designate that a particular property is associated with a particular object. For this example, here is how you add a speed property to the Critter object.
Build a property by referring to it.
Create properties in the constructor.
You can technically create or refer to a property anywhere, but normally they’re created in the constructor.
Use the property like any other variable.
The property acts like any other variable, so you can use it to actually change the speed of the object.