An exception occurs when an expression yields a result that was not expected when you evaluate it. In numerical expressions, the NaN value is provided for just such a circumstance. NaN represents a numeric quantity that cannot be resolved within the range of meaningful values. The interpreter knows it is numeric but the value is wrong. The undefined and Infinity values also help in the management of such exceptions.
The DOM level 1 specification describes an enumerated set of exception codes as follows: