Skip to content

Instantly share code, notes, and snippets.

@josephjunker
Created November 5, 2015 22:55
Show Gist options
  • Save josephjunker/e55c24071d3da6e94d47 to your computer and use it in GitHub Desktop.
Save josephjunker/e55c24071d3da6e94d47 to your computer and use it in GitHub Desktop.
I learned a new feature of JS today
function fib() { if(!x()) return z(); return fib(x(), y(), z()); }
function x() { return fib.arguments[0] - 1; }
function y() { return fib.arguments[2] || 0; }
function z() { return (fib.arguments[1] || 0) + (fib.arguments[2] || 1); }
[fib(1), fib(2), fib(3), fib(4), fib(5), fib(6)].join(); // returns '1,1,2,3,5,8'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment