Created
March 21, 2020 18:04
-
-
Save sheronw/62f6e9c8fb3bf43d092a949629ddeb3f to your computer and use it in GitHub Desktop.
different between for...in and for...of #js
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
let list = [6,8,10]; | |
list.tag = "hello"; | |
// values of the numeric properties of the object being iterated | |
for(i of list) { // 6 8 10 | |
console.log(i) | |
} | |
// keys on the object being iterated | |
for(i in list) { // 0 1 2 tag | |
console.log(i) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment