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

The specified initialization vector (IV) does not match the block size for this algorithm