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

A quick tutorial for OWASP ZAP tool for beginners

ionic2 cordova build android - Unable resolve gradle 2.2.3