75年生人,程序员,在西安。

ES6 Generators 简单理解

ES6 Generators (点击看原文)简单理解:

function *foo(x) {

    var y = 2 * (yield (x + 1));

    var z = yield (y / 3);

    return (x + y + z);

}

var it = foo( 5 );

// note: not sending anything into `next()` here

console.log...

© 世风十三 | Powered by LOFTER