حلقات التكرار في JavaScript:
for (let i = 0; i < 3; i++) { }
while (condition) { }
do { } while (condition); // runs at least once
for (const item of items) { } // values of an array
for (const key in obj) { } // keys of an object
وforEach؟
forEach ليست كلمة من كلمات اللغة، بل دالة في المصفوفات، وتُكتب بحرف E كبير:
items.forEach(item => console.log(item));
ولا توجد كلمة اسمها loop في JavaScript.