Uncaught RangeError: Maximum call stack in JavaScript

Robin Jangu

Posted On: March 28, 2018

view count15403 Views

Read time2 Min Read

Errors occur where you least expect them, JS developers face this nemesis on a daily basis.

There are 2 ways to get these wonderful error messages:

1) Non-Terminating Recursive functions

Browser allocates memory to all data types. Sometimes calling a recursive function over and over again, causes the browser to send you this message as the memory that can be allocated for your use in not unlimited.

There is nothing painful for a coder than a non-terminating function or a method of recursion that tends to get stuck in an infinite loop.

Be considerate while calling functions, also dry run is the best practice to prevent them.

Maximum call stack gets overflow and washes away your hopes of running the code correctly.(XD)

2) Out of Range

If someone asks you what your name is.

You won’t reply ‘2000 yrs’.

Certain functions in JavaScript have ranges of inputs that you can give. Always be careful of the ranges. Sometimes while scripting we use functions that in the end go out of range, while performing tasks. These errors can be easily tackled, if while implementation you keep track of the ranges of variable types used.

While browsers like Chrome will give error notifications, IE will crash.

It should be of utmost priority that you check the valid input ranges.

Examples:

Number.toFixed(digits) 0 to 20

Number.toPrecision(digits) 1 to 21

Number.toExponential(digits) 0 to 20

Null is not 0

Hopefully this blog will help coders a bit in their frustrating hard work.

Let us learn from your mistakes too, please comment.

Author Profile Author Profile Author Profile

Author’s Profile

Robin Jangu

Robin is a Tech Blogger and Social Media Marketer.

Blogs: 19



linkedintwitter

Test Your Web Or Mobile Apps On 3000+ Browsers

Signup for free