Summary
In Chapter 2, Primitive Data Types, Arrays, Loops, and Conditions, you saw that there are five primitive data types (number, string, Boolean, null, and undefined) and we also said that everything that is not a primitive piece of data is an object. Now you also know that:
- Objects are like arrays, but you specify the keys.
- Objects contain properties.
- Properties can be functions (functions are data; remember
var f = function () {};
). Properties that are functions are also called methods. - Arrays are actually objects with predefined numeric properties and an auto-incrementing
length
property. - Array objects have a number of convenient methods (such as
sort()
orslice()
). - Functions are also objects and they have properties (such as
length
andprototype
) and methods (such ascall()
andapply()
).
Regarding the five primitive data types, apart from undefined
and null
, the other three have the corresponding constructor functions: Number()
, String()
, and Boolean()
. Using these, you can create objects...