Languages
[Edit]
EN

JavaScript - loops: for, while, do while

7 points
Created by:
Giles-Whittaker
739

In this article, we would like to show you a few kinds of loops available in JavaScript.

1. for loop examples

Edit

1.1. Classic for loop example

Edit

1.2. Foreach loop (for...of loop) over array example

Edit

Note: this loop has been added in ECMAScript 2015 (6th Edition).

1.3. for...in loop over object example

Edit

Note: for...in loop only iterates over enumerable and non-Symbol properties.

2. while loop example

Edit

3. do...while loop example

Edit

4. break keyword with loop example

Edit

4.1. Classic for loop with beak operation example

Edit

4.2. Foreach loop (for...of loop) over an array with break operation example

Edit

Note: this loop has been added in ECMAScript 2015 (6th Edition).

4.3. for...in loop over an object with break operation example

Edit

Merged questions

Edit
  1. js for
  2. javascript for
  3. js while
  4. javascript while

See also

Edit
  1. JavaScript - for, for-each and forEach performance test

Alternative titles

  1. js for loop
  2. js for, while, do while loop
  3. js while loop
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

JavaScript - Statements & declarations

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join