Chapter 4. The JavaScript Objects
The JavaScript objects are inherent components of the JavaScript language itself, and not the environment in which the JavaScript is processed. As such, they’ll always be available regardless of environment.
Among the basic JavaScript objects are those that parallel our data
types, which we discussed in Chapter 2: String for strings, Boolean for booleans, and of course, Number for numbers. They
encapsulate the primitive types, providing additional functionality beyond
the basic conversion functionality we discussed in that chapter.
Three additional built-in objects provide necessary functionality
as well: Math, Date, and RegExp. Math
and Date are relatively self-explanatory;
they provide basic math and date functionality. If you haven’t worked with
regular expressions before, RegExp is the object that provides regular
expression functionality. Regular expressions are powerful though extremely
cryptic patterning capabilities that enable you to add very precise string
matching to applications.
JavaScript also has one built-in aggregator object, the Array. All objects in JavaScript, in fact, are arrays, though we don’t
typically treat the objects as arrays. I’ll discuss this in more detail
later in the chapter. First, though, we’ll revisit the basic data type
objects introduced earlier, as we explore exactly what it means to be an
“object” in JavaScript.
Primitive Data Types As Objects
I’ll get into the details of JavaScript’s object-oriented nature later ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access