can also use the
Boolean
constructor (again, without the
new
keyword) to achieve the
same result:
const
n
=
0
;
// "falsy" value
const
b1
=
!!
n
;
// false
const
b2
=
Boolean
(
n
);
// false
Conclusion
The data types available to you in a programming language are your basic building
blocks for the kind of things you can express in the language. For most of your day-
to-day programming, the key points you want to take away from this chapter are as
follows:
• JavaScript has six primitive types (string, number, boolean, null, undefined, and
symbol) and an object type.
• All numbers in JavaScript are double-precision floating-point numbers.
• Arrays are special types of objects, and along with objects, represent very power‐
ful and flexible data types.
• Other data types you will be using often (dates, maps, sets, and regular expres‐
sions) are special types of objects.
Most likely, you will be using strings quite a lot, and I highly recommend that you
make sure you understand the escaping rules for strings, and how string templates
work, before proceeding.
54 | Chapter 3: Literals, Variables, Constants, and Data Types