Java Reference
In-Depth Information
Figure 5-7
The cinema booking system you have created is very basic to say the least! However, it gives you an
idea of how creating your own reference types can be used to help make code more maintainable and
be used to model real-world problems and situations.
Summary
In this chapter you've taken a look at the concept of objects and seen how vital they are to an under-
standing of JavaScript, which represents virtually everything with objects. You also looked at some of
the various native reference types that the JavaScript language provides to add to its functionality.
You saw that:
JavaScript is object-based — it represents things, such as strings, dates, and arrays, using the
concept of objects.
Objects have properties and methods. For example, an
Array object has the length property
and the sort() method.
To create a new object, you simply write
new ObjectType() . You can choose to initialize an
object when you create it.
To set an object's property's value or get that value, you simply write
ObjectName.
ObjectProperty.
Calling the methods of an object is similar to calling functions. Parameters may be passed, and
return values may be passed back. Accessing the methods of an object is identical to accessing a
property, except that you must remember to add parentheses at the end, even when there are no
parameters. For example, you would write ObjectName.ObjectMethod() .
Search WWH ::




Custom Search