What is the use of loop in javascript
Loop executes the same code of block again and again. Loop is a control flow statement for specifying iteration, which allows code to be executed repeatedly. Repetitive task within a program to save time and effort.
Mainly javascript support 5 types of loops:
for
for…in
for…of
While
do…while
Don’t miss bonus tips at last it’s very useful for looping.
For loop is control flow statement for specifying an iteration. Which allow to execute code in repeated manner.
//Syntax:
for(Declaration; condition; Increment / decrement){
// Your Logic here
// Statement
}
Declaration: It’s used for variable Declared or counter variable, Many developers said the scope of the loop as well.
Condition: Execution of loop is base on condition. If condition is true code is executed. Stop execution if the condition is false.
expression: Expression run after every iteration it might be Increment or decrement.
Statement: This is the body of for loop it executes if the condition is satisfied.
#javascript knowledge #javascript developer #javascriptblog #loop