Skip to content

Instantly share code, notes, and snippets.

@Shakil-Shahadat
Last active June 20, 2024 19:07
Show Gist options
  • Save Shakil-Shahadat/475819cf386c5b41fec5f8bec5f5997f to your computer and use it in GitHub Desktop.
Save Shakil-Shahadat/475819cf386c5b41fec5f8bec5f5997f to your computer and use it in GitHub Desktop.
[ Delete ] Summary of 'for / in' & 'for / of' loop
let fruits = [ 'apple', 'orange', 'mango' ];
// for / of loop
for ( e of fruits )
{
// e is now an element of the array
console.log( e ); // Output: apple, orange, mango
}
// for / in loop
for ( i in fruits )
{
// i is now an index of the array
console.log( i ); // Output: 0, 1, 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment