In Chapter 2, 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.
Some of the properties can be functions (functions are data,
var f = function(){};
). Properties that are functions are also called methods.Arrays are actually objects with predefined numeric properties and a
length
property.Array objects have a number of useful 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
(which is essentially nothing) and null
(which is also an object), the other three have corresponding constructor functions: Number()
, String()
, and Boolean()
. Using these, you can create objects, called wrapper...