RangeError

About

The RangeError class is a subclass of Error that is thrown when a value is passed to a function that is out of the range allowed by the function.

This can be encountered when:

  • Passing a string that is not one of the allowed string values, e.g. passing an empty string to a function that expects a non-empty string.

  • Attempting to access an array or collection element that is out of range.

  • Passing a number that is not one of the allowed number values, e.g. passing a negative number to a function that expects a non-negative number.

Last Updated:
Contributors: Aparajita