I'm not too familiar with javascript but here goes.
First a bit of background. The way you have discovered to calculate the fibonacci numbers is known as dynamic programming.
Now the good thing about dynamic programming is that it enforces the idea of building a solution. That is, you start by solving a problem similar to the one you are trying to solve but you start by focusing on the smallest aspect of it, which then allows you to build on that solution to solve an even more complex problem
What's the point of my ramble? I noticed you were employing dynamic programming in solving this problem, but you missed one thing which was reusing the other solutions you already got. Not reusing your solutions leads to an exponential time algorithm which doesn't scale well with larger input.
Solution
Store the results of previous solutions and use them to solve the larger ones
fibonacci = function (n) {
var fib = [0, 1]
return function memoizedFib(n) {
if (!fib[n]) {
fib[n] = memoizedFib(n - 1) + memoizedFib(n - 2);
}
return fib[n];
}(n);
};
See this post for another method of computing fibonacci