Loop in JavaScript

Loop in JavaScript is used to execute some block of code, multiple times based on the condition/requirement. For example:

HTML with JavaScript Code
<!DOCTYPE html>
      let x = 2;
      for(let i=1; i<=10; i++)

The output produced by above JavaScript example is shown in the snapshot given below:

javascript loop example

In above example, the following statement:


will be executed for 10 times with value of i from 1 to 10. The detailed description, about how a for loop executes, is given in its separate tutorial.

List of All Types of Loop in JavaScript

  1. for Loop
  2. while Loop
  3. do...while Loop

JavaScript Online Test

« Previous Tutorial Next Tutorial »

Follow/Like Us on Facebook

Subscribe Us on YouTube