Chapter 8. The Boolean, Number, and Math Objects
Boolean object (a vehicle for
false values), the
Number object, and the
String object, the
Number objects are at the same time primitives as well as objects. They are simultaneously a value as well as a collection of tools for dealing with those data types. As with strings, the distinction is subtle and rarely comes up in practice. However, if you're doing any complex work with these objects, it's worth knowing the difference. Later I'll be talking about the
Math object too, which is useful for working with numbers. If you're not confident with math concepts, don't worry — the
Math object is nothing to fear. It's mainly a basic collection of static utility functions and mathematical constants found in most programming languages. You'll be surprised how often you end up using
Math, usually to do something simple like round off decimals to the nearest whole number, or choose the highest value between a set of values.
The Boolean Object
One of the simplest data types is the primitive boolean value, which can be equal one of two values:
false. Whether you know it or not, you're constantly working with boolean values. Whenever you use an
if statement, ...