Created
July 9, 2018 03:28
-
-
Save GeKiStolyarov/aca3b17af6cf1b1c1c2ec7d7c49afdd0 to your computer and use it in GitHub Desktop.
for...in and for...of
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
const browsers = ['Chrome', 'Firefox', 'Edge', 'Safari', 'Opera']; | |
// for in | |
for (const browser in browsers) { | |
console.log(browser, '---', browsers[browser]); | |
} | |
// output | |
// "0" "---" "Chrome" | |
// "1" "---" "Firefox" | |
// "2" "---" "Edge" | |
// "3" "---" "Safari" | |
// "4" "---" "Opera" | |
// for of | |
for (const browser of browsers) { | |
console.log(browser); | |
} | |
// output | |
// "Chrome" | |
// "Firefox" | |
// "Edge" | |
// "Safari" | |
// "Opera" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment