Conclusion

looping #3: 13msUncaught RangeError: Maximum call stack size exceededSurprised!!!For looping, it got executed successfully with output as Infinity.But for Recursion, it got errored out. This is because once you call recursion it adds up all the function calls to the call stack and finally it exceeds the limit. There is stack size or memory exhaustion per browser which ensures the number of calls that can be present in a stack at any point in time.Recursion is less time consuming compared to Looping in most of the cases. But there should be a breaking condition in place for the Recursion functions to ensure it should not exceed the call stack limit to error-out.Please try out the same example here