es6 for of

//for of 用来遍历 set map generator 
var engines = new Set(["Gecko", "Trident", "Webkit", "Webkit"]);
for (var e of engines) {
  console.log(e);
}




var es6 = new Map();
es6.set("edition", 6);
es6.set("committee", "TC39");
es6.set("standard", "ECMA-262");
for (var [name, value] of es6) {
  console.log(name + ": " + value);
}


function* gen(){
yield 1;
yield 2;
yield 3;
}
var g=gen()
for(var a of g){
console.log(a);
}

你可能感兴趣的:(es6 for of)