Skip to main content
D
JavaScript
JavaScript For Loop

JavaScript For Loop

JavaScript for loops repeat a block of code a specific number of times.

Read Time
5 min read
Difficulty
Beginner
Last Updated
Jun 15, 2026
Version
v1.0.0

Introduction

JavaScript uses loops to run the same code over and over again without copying and pasting. The `for` loop is perfect when developers know exactly how many times the code needs to run.

Example

Example
1/* this loops 5 times */
2for (let i = 0; i < 5; i++) {
3  console.log("Number: " + i);
4}

Key Points

  • Statement 1 runs once before the loop starts.
  • Statement 2 defines the condition to keep looping.
  • Statement 3 runs at the end of every loop.
  • Loops are commonly used to read through arrays.

Up Next

Continue your journey with the next topic.

Go to JS While Loop