Skip to content

Instantly share code, notes, and snippets.

@miensol
Created June 14, 2014 07:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miensol/367d27fb1b3f7966e31a to your computer and use it in GitHub Desktop.
Save miensol/367d27fb1b3f7966e31a to your computer and use it in GitHub Desktop.
es6 fibonaci generator
var fibo = function *(){
var a = 0,
b = 1;
yield a;
yield b;
while(true){
var next = a + b;
yield next;
a = b;
b = next;
}
};
var fiboGenerator = fibo();
var current = null;
while(!(current = fiboGenerator.next()).done){
console.log(current.value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment