For the More Curious: JavaScript Types

Throughout the chapter, you created variables so you could refer to some data inside your functions. Early on, we told you that strings, numbers, and Booleans are three of the five primitive data types. The other two types are null and undefined.

Table 6.2 summarizes the properties of the five primitive types.

Table 6.2  Primitive data types in JavaScript

Type Example Description
string “And you get $100! And you get $100! And…!” Letters, numbers, or symbols enclosed in matching quotation marks.
number 42, 3.14159, -1 Whole numbers and decimals.
Boolean true, false The keywords true and false, corresponding to logical true and false.
null null The value that denotes an invalid value.
undefined undefined The value of a variable that has not been assigned to anything.

All other types in JavaScript are considered compound types or complex types. These include arrays and objects, which can have other types inside of them. For example, you wrote a function that produced an array of thumbnail objects. Arrays also have properties (like length) and methods (such as forEach).

You will continue to work with primitive and complex data types throughout this book.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.128.173.53