HTML and CSS Reference
second is always left over each day. As the days accumulate, these fractions of a second
add up. Most time devices, such as atomic clocks, account for this accumulation by
adding a leap second on certain days of the year. The effect of adding these leap seconds
is going on in calculating the time difference between one date and another than may
appear at first glance.
provides several methods that allow you to examine the properties of numbers and
specify how they're displayed on a Web page.
Handling Illegal Operations
Some mathematical operations can return results that are not numeric values. For
example, you cannot divide a number by a text string. If you attempted to perform the
var x = 5/”A”;
in a script, the Web page would display the text string NaN , which stands for not a
should involve a numeric value, but doesn't. You can check for the presence of this par-
ticular error using the isNaN() function
isNaN( value )
where value is the value or variable you want to test for being numeric. The isNaN()
function returns a Boolean value: true if the value is not numeric, and false otherwise.
The use of the isNaN() function is one way to locate illegal operations in code in which
non-numeric values are treated as numeric.
Another illegal operation is attempting to divide a number by 0, as in the following code:
var x = 5/0;
This code results in the value Infinity being written to the Web page. The Infinity
value indicates that you've attempted a numeric calculation whose result is greater than
to numeric values that fall between approximately 1.8 × 10 -308 and 1.8 × 10 308 . Any
to assign a value of Infinity to the result. You can check for this outcome using the
isFinite( value )