[ES6] Generators

Example 1:

function *topicList(){
yield "ES2015";
yield "Semi-colons: good or bad?";
yield "TypeScript";
} for( let topic of topicList() ){
console.log( topic );
}

Example2:

let user = {
name: "sam", totalReplies: 17, isBlocked: false
}; user[Symbol.iterator] = function *(){ let properties = Object.keys(user); for(let p of properties){
yield this[p];
}
}; for(let p of user){
console.log( p );
}
上一篇:《Toward an SDN-Enabled Big Data Platform for Social TV Analysis》--2015--Han Hu


下一篇:答:SQLServer DBA 三十问之五:有关视图索引