Simply speaking an objejct is a collection of properties and functions. Objects are very useful to organise data or information.
var dt = new Date();
Accessing Object Properties
The syntax for accessing a property of an object is:
The following code demonstrates the use of the length property of the string object:
var domain = "pickatutorial.com";
var len= domain.length;
// the variable len now has the value 17
Calling / Invoking Object Functions
Functions usually perform some action on the object properties. The syntax for invoking a function on some object is as under:
The following code converts our text to lowercase:
var domain = "PICKATUTORIAL.COM";
var lower = domain.toLowerCase();
// the value of variable lower now equals pickatutorial.com
If you have some prior programming experience of any object oriented programming language like c++, you may have an idea of classes. The concept of classes is very integral to the concept of objects in any object oriented programming langauge.