|
|
Objects
Objects are basically the king of all data types. Not only can they contain any number
of variables of other data types at the same time, but they can contain
other objects. Objects are also capable of learning all of the variable
names and data from other objects. Programmers are able to add behaviors to objects
to allow them to manipulate data in a controlled way, but we well get into that
later. Behaviors added in this way can be learned by other objects.
It is important to note that many older
programming languages do not support the data type object, but they should generally
be avoided.
Important Notes
Each variable inside of an object is known as a property.
The process of one object learning properties and behaviors from another object is known as inheritance.
The object that you inherit from is known as a base class.
One object can inherit from multiple base classes.
Some programming languages have built in object types for you to work with.
Just a hint: Some common built in object types are String, Integer, Boolean and
Array (we will talk more about this later).
Example:
var Ball = new Object();
Ball.isRound = true;
Ball.Colors = ["green", "white"];
Ball.Size = 12;
Ball.Weight = 2.3;
var TennisBall = new Ball();
TennisBall.NumStripes = 2;
TennisBall.canBounce = true;
|
|
|
|
Previous Page:
Arrays,
Next Page:
Databases. |
|