Built-in objects
Earlier in this chapter, you came across the Object()
constructor function. It's returned when you create objects with the object literal notation and access their constructor
property. Object()
is one of the built-in constructors; there are a few others, and in the rest of this chapter you'll see all of them.
The built-in objects can be divided into three groups:
Data wrapper objects: These are
Object
,Array
,Function
,Boolean
,Number
, andString
. These objects correspond to the different data types in JavaScript. There is a data wrapper object for every different value returned bytypeof
(discussed in Chapter 2, Primitive Data Types, Arrays, Loops, and Conditions), with the exception ofundefined
andnull
.Utility objects: These are
Math
,Date
, andRegExp
, and can come in handy.Error objects: These include the generic
Error
object as well as other more specific objects that can help your program recover its working state when something unexpected happens.
Only a handful...