Skip to content

Instantly share code, notes, and snippets.

@kevinchisholm
Last active February 1, 2018 14:33
Show Gist options
  • Save kevinchisholm/c9678a142b471d71715bba13c007fffb to your computer and use it in GitHub Desktop.
Save kevinchisholm/c9678a142b471d71715bba13c007fffb to your computer and use it in GitHub Desktop.
var days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday'];
for (var day in days) {
console.log(day);
}
/*
OUTPUT:
0
1
2
3
4
5
*/
var days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday'];
for (var day in days) {
console.log(days[day]);
}
/*
OUTPUT:
monday
tuesday
wednesday
thursday
friday
*/
var days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday'];
for (var day of days) {
console.log(day);
}
/*
OUTPUT:
monday
tuesday
wednesday
thursday
friday
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment