Skip to content

Instantly share code, notes, and snippets.

@prof3ssorSt3v3
Created August 19, 2017 21:03
Show Gist options
  • Save prof3ssorSt3v3/8494cc224bb6e2d3c6adde613ab97725 to your computer and use it in GitHub Desktop.
Save prof3ssorSt3v3/8494cc224bb6e2d3c6adde613ab97725 to your computer and use it in GitHub Desktop.
// for..of loops
// for..of versus for..in loops
let supernatural = {
"actors":['Jared Padelecki', 'Jensen Ackles', 'Mark Sheppard', 'Misha Collins'],
"characters":['Sam Winchester', 'Dean Winchester', 'Crowley', 'Castiel'],
"seasons":12 };
for( prop in supernatural){
console.log( prop, typeof supernatural[prop],
Array.isArray(supernatural[prop]) );
}
for( prop in supernatural.actors){
console.log(prop, supernatural.actors[prop]);
}
for( name of supernatural.actors){
console.log( name );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment