JavaScript Recursion vs Iteration performance analysis