decode now
  • Home
  • Blog
    • AI
    • Backend
      • Java
    • Career & Interviews
    • Frontend
      • HTML
      • CSS
      • JavaScript
    • Full Stack
  • Notes
  • About us
  • Contact US
No Result
View All Result
AI News
  • Home
  • Blog
    • AI
    • Backend
      • Java
    • Career & Interviews
    • Frontend
      • HTML
      • CSS
      • JavaScript
    • Full Stack
  • Notes
  • About us
  • Contact US
No Result
View All Result
Decode Now
No Result
View All Result
JavaScript Loops

JavaScript Loops

admin by admin
June 7, 2026
in JavaScript
0
585
SHARES
3.2k
VIEWS
Summarize with ChatGPTShare to Facebook

Last Updated on June 7, 2026 by admin

JavaScript Loops

Hello Bloggers, Welcome to Decode Now.  In this blog we will discuss about JavaScript Loops. We’ll embark on a journey into the world of JavaScript loops, exploring their types, syntax, and practical applications.

– In JavaScript, loops are used to perform repeated tasks based on a condition.
A loop is a programming tool that is used to repeat a set of instructions.

– There are four types of loops in JavaScript are:-
1. for loop
2. for-in loop
3. for-of loop
4. while loop
5. do-while loop

– JavaScript Loop:- For Loop

-> A for loop is a control flow statement that allows you to repeatedly execute a block of code a specified number of times.

– The syntax of for loop is given below:
for (initialization; condition; increment)
{
code to be executed
}

– Here’s an example of a for loop that counts from 1 to 5 and prints the numbers:
-> 
Initialization: ‘let i = 1’ initializes a variable ‘i’ to 1.
-> Condition: ‘i <=5’ is the condition that checks if ‘i’ is less than or equal to 5.
-> Iteration: ‘i++’ increments the value of ‘i’ by 1 in each iteration.
The loop will execute as long as ‘i’ is less than or equal to 5, and it will print the numbers 1 through 5.

– JavaScript Loop:- For-in loop

-> The for-in loop iterates over the properties of an object.

– The syntax of for loop is given below:
for (variable in object) {
// Code to be executed for each property
}

– Here’s an example of using a ‘for-in’ loop to iterate over the properties of an object :
-> In this example, the ‘for-in loop iterates over the properties of the ‘person’ object, and for each property, it prints the property name and its corresponding value.

– JavaScript Loop:- For-of loop

-> The for-of loop is used for iterating over the values of iterable objects such as arrays, strings, maps, sets, and more.
-> A for-of loop operates on the values sourced from an iterable one by one in sequential order.

– The syntax of for-of loop is given below:
for (variable of iterable) {
// Code block to be executed
}

– Let’s see the example of for of loop in javascript:
const numbers = [1, 2, 3, 4, 5];

for (const number of numbers) {
console.log(number);
}

– JavaScript Loop:- While Loop

-> A while loop in JavaScript is a control flow statement that allows you to execute a block of code repeatedly as long as a specified condition evaluates to true.

– The syntax of while loop is given below:
while(condition) {
//Code block to be executed
}

– Let’s see the example of while loop in javascript:
<script>
var i=18;
while(i<=20)
{
document.write(i + “br/>”);
i++;
}
</script>

 

–  JavaScript Loop:- Do-While Loop

-> The do-while loop executes the code block at least once, and then it checks the condition. This means that the code block is executed once before the condition is tested.

-> The syntax of do-while loop is given below:
do {
//Code block to be executed
} while (condition);

– Let’s see the example of do-while loop in javascript:
let count=0;
do {
console.log(count);
count++;
} while (count < 5)

 

 

Note :-

  • If you want to learn Javascript Loops, Above are the key points which will help you to learn more about it.
  • Also, if you like this post or have any queries, Do let me know in the comments.
  •  Below are the resources to learn more about Javascript.
 

Resources :-

  • Geeks for Geeks
  • W3School
  • Javascript.info
  • Programiz  |
SummarizeShare234
admin

admin

Related Stories

Mastering JavaScript Error Handling

Mastering JavaScript Error Handling

by admin
June 7, 2026
1

Mastering JavaScript Error Handling   Introduction: JavaScript, as a versatile and powerful programming language, has become the backbone of modern web development. However, like any programming language, it's...

JavaScript Closure

JavaScript Closure

by admin
June 16, 2026
0

Understanding JavaScript Closure JavaScript closures are a fundamental concept that plays a crucial role in the language's functionality. They enable developers to create powerful and flexible code structures...

Understanding JavaScript Hoisting

by admin
June 14, 2026
0

Understanding JavaScript Hoisting JavaScript hoisting is a crucial concept that affects how variables and functions are processed during the compilation phase before code execution. It refers to the...

Introducing JavaScript Object Methods

Introducing JavaScript Object Methods

by admin
June 16, 2026
0

JavaScript Object Methods In JavaScript, objects play a crucial role in representing real-world entities or concepts. They encapsulate data, known as properties or attributes, and the methods (actions...

Next Post
Javascript scopes

JavaScript Scopes

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Decode Now

Learn. Build. Grow. Explore programming tutorials, development roadmaps, interview preparation guides, and career resources designed for aspiring developers.

Follow us

Recent Posts

JavaScript Document Object Model

JavaScript Document Object Model

June 7, 2026
JavaScript arrow functions & regular functions

JavaScript Arrow Functions & Regular Functions

June 7, 2026

Weekly Newsletter

  • Decode Now
  • Blogs
  • Contact US
  • About us

© 2026

No Result
View All Result
  • Home
  • Blog
    • AI
    • Backend
      • Java
    • Career & Interviews
    • Frontend
      • HTML
      • CSS
      • JavaScript
    • Full Stack
  • Notes
  • About us
  • Contact US

© 2026