+ 6
What os the difference between loops and statements in javascript
5 Answers
+ 6
Like this :
while (statements) {
//do something.
}
+ 5
Loops will occur while the statements are true.
+ 5
The difference between loops and statements in ANY language is this:
Loops are for doing something repeatedly.
Statements are for doing something once.
E.g. (specifically for js)
for(var i=0; i<100; i++)
{
console.log(i);
}
//outputs all numbers from 0 to 99
console.log(5);
//outputs 5 once
+ 1
If you are talking about conditional statement and loops
Conditional Statement :
Conditional statement are used to control the flow means if some condition is true than only execute certain statement.
Loops :
Loops are used to repeat a block of statement if certain condition are true.
Hope this helpsâșïžâșïž.
0
Depending on the type of loop, the loop just makes a piece of code run i # of times, or for each occurrence of a variable in a container (array, vector...), or until a condition set by the user becomes true.
The conditions of the loop's stopping point and the code in the body of the loop are your statements in a loop.
A statement can run only once outside of a loop also.