News for hackers. Stuff that matters.

symbiosis

This is just custom iterator/generator. Saw many like this before Babel.

The point is that ES2015 defines clear interface for iterating over iterables. With help of Symbol and *.

If you would use this code in production, probably you would document it: ... returns iterator function.

  next = fib()
  next() // 0
  next() // 1
  next() // 1 ...
But if you would use Symbol.iterator

then you can do

  for (f of fib()) 
    console.log(f)
or use gathering, spreading etc..
Re:Stop using React for everything on Wednesday August 26, 2015 @11:19AM (#10123476)
React is eating the world. Reactify all the things!
Re:Constructor Theory on Sunday May 03, 2015 @04:51AM (#9480538)
So how did Bellatrix Lestrange escape from the Azkaban?