When you write object-oriented code, you have more control and flexibility. Rather than writing procedural code which is used just one time, object based
languages allow you to reuse code over and over again.
An object is a collection of properties. These properties can be primitive data types, other objects, or methods (functions).
can use. Some examples include the Image, String, Math, Date, and Array. Here is an example of creating a new custom object:
var myObj = new Object();
Once we create our new myObj object, we can access its properties such as "name" and "age". For example, if we want to assign the name
of the myObj, we would simply assign it as follows: myObj.name="John".
In the previous example, you just saw that we assigned the name of the new myObj object a value. The
"name" is a property of the myObj object. Properties are the values associated
with an object. In this next example we will use the length property of the String object to return the number of characters in the string.
Methods are the actions that can be performed on objects. Methods are functions of the object. In the following example we are using the bold()
method of the String object to display the string text in bold styling:
Recommended Books & Training Resources