06.07.2017 Views

Mastering JavaScript

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>JavaScript</strong> Primer<br />

<strong>JavaScript</strong> supports the standard variations of types:<br />

• Number<br />

• String<br />

• Boolean<br />

• Symbol (new in ECMAScript 6)<br />

• Object:<br />

• Null<br />

° ° Function<br />

° ° Array<br />

° ° Date<br />

° ° RegExp<br />

• Undefined<br />

Number<br />

The Number type can represent both 32-bit integer and 64-bit floating point values.<br />

For example, the following line of code declares a variable to hold an integer value,<br />

which is defined by the literal 555:<br />

var aNumber = 555;<br />

To define a floating point value, you need to include a decimal point and one digit<br />

after the decimal point:<br />

var aFloat = 555.0;<br />

Essentially, there's no such thing as an integer in <strong>JavaScript</strong>. <strong>JavaScript</strong> uses a 64-bit<br />

floating point representation, which is the same as Java's double.<br />

Hence, you would see something as follows:<br />

EN-VedA:~$ node<br />

> 0.1+0.2<br />

0.30000000000000004<br />

> (0.1+0.2)===0.3<br />

false<br />

[ 8 ]<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!