javascript function * declaration



Did you know that if you defined your javasscript function  like function *, you're basically creating a iterator function.

var myIterable = {}
myIterable[Symbol.iterator] = function* () {  // i want a iterator here! :)
    yield 1;
    yield 2;
    yield 3;
};
[...myIterable] // [1, 2, 3]

Comments

Popular posts from this blog

ionic2 cordova build android - Unable resolve gradle 2.2.3

OpenCover code coverage for .Net Core

Using Custom DLL with IronPython / Scripts