in ES5, we have a for ... in:
var phones = ["IPhone", "Nexus", "Nokia"]; for inch phones) { console.log (phones[i]);} // IPhone // Nexus // Nokia
What we get from for...in is index of array.
in ES6, for ... of can get value from array:
var phones = ["IPhone", "Nexus", "Nokia"]; for (phone of phones) { console.log (phone);} // IPhone // Nexus // Nokia
Using for...of on object:
varES6 ={edition:6, Committee:"TC39", Standard:"ECMA-262"}; for(Einches6) {Console.log (e);}//Edition//Committee// Standardvarengines = Set (["Gecko", "Trident", "Webkit", "Webkit"]); for(vare of engines) {Console.log (e);}//Gecko//Trident//WebkitvarES6 =NewMap (); Es6.set ("Edition", 6); Es6.set ("Committee", "TC39"); Es6.set ("Standard", "ECMA-262");
for(var[Name, value] of ES6) {Console.log (name+ ": " +value);}//Edition:6//committee:tc39//standard:ecma-262
See MORE:HTTP://JAVASCRIPT.RUANYIFENG.COM/ADVANCED/ECMASCRIPT6.HTML#TOC17
[ES6] 19. For ... of