Created
December 10, 2014 20:57
-
-
Save devdays/20bb80b9a8608d961ed1 to your computer and use it in GitHub Desktop.
Object JavaScript ECMAScript 6 for-of loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// outputs elements not indices | |
let myArray = ['hello', 'world']; | |
for (let elem of myArray) { | |
console.log(elem); | |
} | |
/* output is | |
hello | |
world | |
*/ | |
// in ECMAScript 6 | |
// using the same array | |
for( let [index, elem] of myArray.entities()) { | |
console.log(index, elem); | |
} | |
/* output is | |
0 hello | |
1 world | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment