Last active
November 22, 2016 09:00
-
-
Save silently/adb078679399a5cb0424 to your computer and use it in GitHub Desktop.
3 ways to iterate over arrays
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
var a = [1, 2, 3, 4, 5]; | |
// standard for loop | |
for (let i = 0; i < a.length; i++) { | |
console.log(a[i]); | |
} | |
// from ES5 | |
a.forEach(function(item) { | |
console.log(item); | |
}); | |
// from ES6 | |
for(let item of a) { | |
console.log(item); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment