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:

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, called wrapper objects, which contain methods for working with primitive data elements.

Number(), String(), and Boolean() can be invoked:

Other built-in constructor functions you're now familiar with include Object(), Array(), Function(), Date(), RegExp(), and Error(). You're also familiar with Math-a global object that is not a constructor.

Now, you can see how objects have a central role in JavaScript programming, as pretty much everything is an object or can be wrapped by an object.

Finally, let's wrap up the literal notations you're now familiar with:

Name

Literal

Constructor

Example

Object

{}

new Object()

{prop: 1}

Array

[]

new Array()

[1,2,3,'test']

Regular expression

/pattern/modifiers

new RegExp('pattern', 'modifiers')

/java.*/img