RangeError

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 Function.prototype
apply, call, toSource, toString, valueOf

RangeError instances

Properties

constructor
Specifies the function that created an instance's prototype.
name
Error name.
Although ECMA-262 specifies that RangeError should provide its own 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

Tags (0)

Edit tags
  • No tags

Attachments (0)

 

Attach file