hide - Understanding jQuery
hide - Understanding jQuery
hide - Understanding jQuery
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
An object is created from a class. And in JavaScript everything is an object by definition. This<br />
is why we never need to use the class keyword in the first place. Everything is already an object.<br />
Whereas in PHP, C++ or Java, this is not true. Conceptually, variables are data types and<br />
not necessarily classes in these languages. There is a clear distinction between variables and<br />
classes in those languages. But not in JavaScript which treats every single data type as an object<br />
by default. This is very important concept to understand and it is part of what makes JavaScript<br />
a prototype-based language. In an object-oriented language the entire program is a collection<br />
of these objects working together.<br />
An object is an initialized class. It is the physical representation of the class in computer memory,<br />
that is ready to be used by your program. While the class is merely a blueprint model, a<br />
design - the object of that class is the constructed result.<br />
The behavior and properties of an object can be defined during the process of object creation,<br />
also known as instantiation of an object. In other words, a new instance of an object is created,<br />
or initialized, from a specific model which is determined by its class.<br />
An object can also be modified by your program during the course of its existence until it is<br />
destroyed or in other words, erased from computer memory.<br />
Classes are the models for spawning new instances of objects. Using one class, you can spawn<br />
any number of different types of cars with different types of engines, transmission systems<br />
or tires. The number of objects that can be created is only limited by memory capacity of the<br />
computer on which your program is running.<br />
An Example of Object Composition. Object-oriented programming languages follow the<br />
same idea as in the real world, where real-life objects are constructed from a number of smaller<br />
objects. A car has an engine and wheels. A light bulb has a glass shape and socket base type.<br />
44