Last active
July 1, 2024 04:41
-
-
Save Shakil-Shahadat/475819cf386c5b41fec5f8bec5f5997f to your computer and use it in GitHub Desktop.
[ Delete ] Summary of 'for / in' & 'for / of' loop
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 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