Working With the Number Type
In this lesson, we will cover the number type in JavaScript. Let's begin!
We'll cover the following...
JavaScript does not make a distinction among types of numbers, such as integers and floating-point numbers with different lengths.
JavaScript only has a single number type that represents both integers and floating point numbers using the IEEE-754 format.
You can check the Number.MIN_VALUE
and the Number.MAX_VALUE
constants to know this representation’s limits:
MIN_VAULE: 5e-324MAX_VALUE: 1.7976931348623157e+308
Despite the single storage format, JavaScript provides several literal formats.
Integer literals
Integer numbers can be represented with decimal, octal, and hexadecimal literals. Most frequently, decimal literals are used:
var smallInt = 73;var longInt = 12345678901234567;var negInt = -162;
When the integer literal starts with 0, it is parsed as an octal literal, unless a digit out of the 0-7 range is detected, in this case, the number ...