Add example of entries() method with for...of loop in JavaScript

Added example of using entries() method with for...of loop. This will show result with index and values.
This commit is contained in:
Ashraf authored and GitHub committed 2025-09-16 14:01:17 +06:00
1 parent 4e7850d5bd
commit 372afc50a7
1 file changed
+7
+7
View File
@@ -761,6 +761,13 @@ for (let fruit of fruits) {
// => apple
// => orange
// => banana
for (let [index, value] of fruits.entries()) {
console.log(index, value);
}
// => 0 apple
// => 1 orange
// => 2 banana
```
## JavaScript Iterators {.cols-2}