Visit Mozilla.org

Core JavaScript 1.5 Reference:Global Objects:RangeError

From MDC


This page documents the use of the RangeError object itself and its use as a constructor. For a list of properties and methods inherited by RangeError instances, see RangeError.prototype.

Contents

[edit] Summary

Represents an error when a number is not within the correct range allowed.

[edit] Syntax

new RangeError([message[, fileName[, lineNumber]]])

[edit] Parameters

message
Human-readable description of the error
fileName
Non-standard
The name of the file containing the code that caused the exception
lineNumber
Non-standard
The line number of the code that caused the exception

[edit] Description

A RangeError is thrown when trying to pass a number as an argument to a function that does not allow a range that includes that number. This can be encountered when to create an array of an illegal length with the Array constructor, or when passing bad values to the numeric methods toExponential, toFixed, or toPrecision.

[edit] Properties

prototype
Allows the addition of properties to an RangeError object.

Properties inherited from Function.prototype
caller, constructor, length, name

[edit] Methods

The global RangeError contains no methods of its own, however, it does inherit some methods through the prototype chain.

Methods inherited from Function.prototype
apply, call, toSource, toString, valueOf

Methods inherited from Object.prototype
__defineGetter__, __defineSetter__, hasOwnProperty, isPrototypeOf, __lookupGetter__, __lookupSetter__, __noSuchMethod__, propertyIsEnumerable, unwatch, watch

[edit] See also