---
title: "What are the iterable statement in JS?"  
description: "What are the iterable statement in JS?"  
author: "Ravi Vishwakarma"  
published: 2021-07-19  
canonical: https://answers.mindstick.com/qa/93731/what-are-the-iterable-statement-in-js  
category: "web application"  
tags: ["javascript", "web application development", "web development services"]  
reading_time: 3 minutes  

---

# What are the iterable statement in JS?

What are the iterable statement in JS?

## Answers

### Answer by user

The JavaScript loops are used to iterate the piece of code using for, while, do while or for-in loops. It makes the code compact. It is mostly used in array. There are four types of loops in JavaScript. 1. for loop 2. while loop 3. do-while loop 4. for-in loop **For loop**

```
 for (declaration ; condition ; updation [increment or decrement]){
  True statement ……
 } another statement
```

**Example:**\

```
 for (var i = 0; i < 20; i++) {
   console.log('i = '+i);
 }
```

**While loop**

```
 declaration
 while(condition){
  true statement;
 updation
 }
```

**Example:**

```
 var i=5;
 while(i<60){
   console.log(i+' ');
   i=i+5;
 }
```

**do-while**

```
 declaration
 do{
  true statement;
 updation
 } while(condition);
```

**Example:**

```
var i=5;
do{
  console.log(i+' ');
  i=i+5;
}while(i<60);
```

**For-in loop** The JavaScript for in statement loops through the properties of an Object.

```
 for (key in object) {
   code block to be executed
 }
```

**Example:**

```
const person = {fname:'shivam', lname:'prajapati', age:45};
let txt = '';
for (let x in person) {
  txt += person[x] + ' ';
}
console.log(txt);
```

\

### Answer by Ethan Karla

In other words, we call the loop statement as iterable statement. JavaScript iterable statements are used to iterate a piece of code using while, while or for-in loops. It is mostly used to access the value in array. We use iterable statement because, if a line of code has to be executed multiple times, then we put that statement in the loop. by which it runs automatically In JavaScript has five types of iterable statement.

1. for loop
2. while loop
3. do-while loop
4. for-in loop
5. for-of loop

Syntax:

```
for-loop    for(variable declaration; condition ; updation)        statement
```

```
while loop    variable declaration;while(condition){            statement;    updation;}
```

```
do-while loop    variable declaration;do{    statement;    updation;}while(condition);
```

```
for-in loopfor( variable in objects)    statement;
```

```
for-of loopfor (variable of iterable) {
  statement
}
```

Example

```
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript For Loop</h2>
<p id='demo'></p>
<script>
const fruits = ['Apple', 'Banana', 'Graps', 'Kiwi', 'Mango', 'Orange'];
let text = '';
for (let i = 0; i < fruits.length; i++) {
  text += fruits[i] + '<br>';
}
document.getElementById('demo').innerHTML = text;
</script>
</body>
</html>
```

![What are the iterable statement in JS?](https://answers.mindstick.com/questionanswer/ee026761-aaa6-4139-b445-7b3abb1331be/images/2a673cdc-ed48-4a54-b85c-5bbcd024b118.png)\


---

Original Source: https://answers.mindstick.com/qa/93731/what-are-the-iterable-statement-in-js

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
