Skip to content

Instantly share code, notes, and snippets.

@sheronw
Created March 21, 2020 18:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sheronw/62f6e9c8fb3bf43d092a949629ddeb3f to your computer and use it in GitHub Desktop.
Save sheronw/62f6e9c8fb3bf43d092a949629ddeb3f to your computer and use it in GitHub Desktop.
different between for...in and for...of #js
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