mirror of
https://github.com/Fechin/reference.git
synced 2026-11-20 21:23:11 +03:00
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:
1 parent
4e7850d5bd
commit
372afc50a7
1 file changed
+7
@@ -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}
|
||||
|
||||
Reference in new issue
Block a user