From 372afc50a736bb07fe8ef6dc323dffa99fed7ded Mon Sep 17 00:00:00 2001 From: Ashraf <54413503+iamashruu@users.noreply.github.com> Date: Tue, 16 Sep 2025 14:01:17 +0600 Subject: [PATCH] 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. --- source/_posts/javascript.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/_posts/javascript.md b/source/_posts/javascript.md index fde1c28..d6ec6bd 100644 --- a/source/_posts/javascript.md +++ b/source/_posts/javascript.md @@ -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}