In JavaScript, a "for" loop is a control flow statement that allows you to repeatedly execute a block of code for a specific number of iterations. It is one of the most commonly used loops and is particularly useful when the number of iterations is known or when you want to iterate over elements in an array or other data structures.
Syntax:
for (initialization; condition; update) {
// Code to be executed for each iteration
}
Here's the breakdown of each part of the "for" loop:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Tutor Joes</title> </head> <body> <script src="js/script.js"></script> </body> </html>To download raw file Click Here
/* for (initialize variable; condition; statement) { // code to be executed } */ for(let i=1;i<=10;i++) { console.log(i); } let arr=[]; for(let i=0;i<100;i+=2) { arr.push(i); } console.log(arr); console.log(arr[49]);To download raw file Click Here
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions