Loops in JavaScript

Switch utasításIterálhatók és for...of

Loops allow you to repeat a block of code multiple times. This is essential for tasks like processing lists, counting, or waiting for conditions.

JavaScript has several loop types, each suited to different situations. We'll cover them all with clear examples.

The for Loop

The most common loop when you know how many times to repeat. It has three parts: initialization, condition, increment.

while Loop

Runs as long as the condition is true. Check the condition before each iteration.

do-while Loop

Similar to while, but the code runs at least once – condition checked after.

break and continue

break exits the loop entirely. continue skips to the next iteration.

Looping Over Arrays

for loop with index or modern for...of/for...in (covered in next lesson).

Infinite Loops (Be Careful!)

Avoid loops without proper exit condition.

Quick Quiz

Az anyagokat átnéztük és ellenőriztük, de hibák továbbra is előfordulhatnak. A tartalom kizárólag oktatási célt szolgál, ezért saját felelősségre használd, és szükség esetén ellenőrizd más forrásokkal is.

✨ Kérdezd Larát — a tanulási partnered

Fedezd fel a személyre szabott tanulási támogatást. Lara elmagyarázza az anyagot, összefoglalja a témákat és megválaszolja a kérdéseidet — az Go csomagtól elérhető.


Lara segít gyorsabban tanulni — kizárólag a ReadyTools Go, Plus és Max tagoknak.

Kövesd nyomon a fejlődésed 🚀

Tanulj egyszerűbben utad nyomonkövetésével teljesen ingyen.