Favorites

JavaScript RangeError Object

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
RangeError
JavaScript Errors · ConstructorThis object is supported by all modern browsers.
Updated 28th November 2026

A RangeError is thrown when a number is outside the range of allowed values, such as an invalid array length or too many digits for toFixed().

Description

A RangeError is thrown when a value is not in the set or range of allowed values. Typical causes are creating an array with a negative length, passing more than 100 digits to toFixed(), an invalid radix for toString(), or a function that calls itself so many times that the call stack overflows ("Maximum call stack size exceeded").

Throw one yourself when an argument has the right type but an unacceptable value, for example a percentage above 100.

A "Maximum call stack size exceeded" error usually points to a recursive function without a working base case, or two functions that keep calling each other. Other sources include String.prototype.repeat() with a negative count, Array.prototype.with() with an index outside the array, an invalid date passed to toISOString(), and unsupported options in Intl formatters. Like all errors, it can be caught with try...catch.

Creating

new RangeError(message)

Example

try {
  new Array(-1);
} catch (err) {
  console.log(err.name, err.message);
}

try {
  (12.5).toFixed(200);
} catch (err) {
  console.log(err.name);
}

Browser Support

The following information will show you the current browser support for the RangeError object. Hover over a browser icon to see the version that first introduced support for this object.

This object is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee