Table of contents
- 1. Summary
- 2. Syntax
- 3. Parameters
- 4. Description
- 5. Properties
- 6. Methods
- 7. RangeError instances
- 7.1. Properties
- 7.2. Methods
- 8. See also
Summary
Represents an error when a number is not within the correct range allowed.
Syntax
new RangeError([message[, fileName[, lineNumber]]])
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
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.
Properties
For properties available on RangeError instances, see Properties of RangeError instances.
- prototype
- Allows the addition of properties to an RangeError object.
Properties inherited from Function.prototype
caller, constructor, length, name
Methods
For methods available on RangeError instances, see Methods of RangeError instances.
The global RangeError contains no methods of its own, however, it does inherit some methods through the prototype chain.
Methods inherited from Object.prototype
__defineGetter__, __defineSetter__, hasOwnProperty, isPrototypeOf, __lookupGetter__, __lookupSetter__, __noSuchMethod__, propertyIsEnumerable, unwatch, watch
RangeError instances
Properties
- constructor
- Specifies the function that created an instance's prototype.
- name
- Error name.
message property, in SpiderMonkey, it inherits Error.prototype.message.
Properties inherited from Error.prototype
fileName, lineNumber, message, name, number, stack
Methods
Although the RangeError prototype object does not contain any methods of its own, RangeError instances do inherit some methods through the prototype chain.
Methods inherited from Error.prototype
toSource, toString
Methods inherited from Object.prototype
__defineGetter__, __defineSetter__, hasOwnProperty, isPrototypeOf, __lookupGetter__, __lookupSetter__, __noSuchMethod__, propertyIsEnumerable, unwatch, valueOf, watch