Java Reference
In-Depth Information
Number can be integers (whole numbers, such as 3) or floating point decimals (often re-
ferred to as just "decimals" or "floats", such as 3.14159). For example:
typeof 3;
<< "number"
typeof 3.14159;
<< "number"
As you can see in the examples above, JavaScript doesn't distinguish between integers and
floating point decimals―they are both given the type of "number" , which is a different
approach to most other programming languages. This is set out in the ECMAScript specific-
ation, although most JavaScript engines will treat integers and floats differently in the back-
ground in order to improve efficiency.
Note: Number Constructor Function
Just like strings, numbers also have a constructor function:
new Number(3)
This is much more verbose than simply writing the number 3 , which is
known as a number literal , so it is recommended that you stick to using
number literals.
Octal and Hexadecimal Numbers
If a number starts with a 0x , it is considered to be in hexadecimal (base 16) notation:
0xAF; // A represents 10, F represents 15
<< 175
Hexadecimal or "hex" numbers are often used for color codes on the Web. You can read
more about them on Wikipedia .
Search WWH ::

Custom Search