Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the different types of loops in JavaScript

Shulou Source: shulou.com Published: 2022-06-01 10:32:25 09月28日 Update

This article mainly introduces "what are the different types of JavaScript cycles". In the daily operation, I believe many people have doubts about the different types of JavaScript loops. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "what are the different types of JavaScript loops?" Next, please follow the editor to study!

JavaScript supports different types of loops:

For- loop code block a certain number of times

The for/in- loop traverses the properties of the object

While- loops through the specified block of code when the specified condition is true

Do/while- also iterates through the specified code block when the specified condition is true.

For cycle

For loops are tools that you often use when you want to create loops.

Here is the syntax of the for loop:

For (statement 1; statement 2; statement 3)

{

Block of code to be executed

}

Execute before statement 1 (code block) starts

Statement 2 defines the conditions for running a loop (code block)

Statement 3 executes after the loop (code block) has been executed

Example

For (var item0; I

Tags: Loops codes statements differences types learning conditions more help utility next instances objects properties tools numbers articles methods times theory Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Xiaomi vpn Linux MariaDB