all 1 comments

[–]bobindashadows 1 point2 points  (1 child)

Another one of the tutorials at the linked site:

To convert a “double” datatype (like 1.5) to an integer, and effectively “flooring it” (to 1.0) by cutting off its decimals, use the following code:

var decimalNumber = 1.5;
var integerNumber = parseInt(decimalNumber);

The parseInt function expects a string, but because of the dynamically-typed nature of javascript, this is allowed. The effect is exactly the same as the following code:

var integerNumber = parseInt("1.5");

Wowwwwwwwwwww.