If you are just looking for a simple function that gets the nth Fibonacci number, you can use phi:
$$\frac{\sqrt5 + 1}2$$
To calculate the nth fibonacci number:
$$fib(n)=round(\phi^n/\sqrt5)$$
I don't know javascript very well, but if you can store the value of phi and square root of 5, you can do:
var SQRT_5 = Math.sqrt(5); var PHI = (SQRT_5 + 1) / 2; var yourself = { fibonacci : function(n) { if (n === 0) { return 0; } if (n === 1) { return 1; } return Math.round(Math.pow(PHI, n) / SQRT_5); } };