In JavaScript, the "for...of" loop is a modern iteration method introduced in ECMAScript 6 (ES6) that allows you to loop over iterable objects, such as arrays, strings, sets, maps, and more. The "for...of" loop provides a more concise and readable syntax for iterating over elements compared to traditional "for" loops.
Syntax:
for (variable of iterable) {
// Code to be executed for each iteration
}
<!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
let names = ["Tiya", "Ram", "Sam", "Raja", "Kumar"]; for(let i=0;i<names.length;i++) { console.log(names[i]); } console.log("For of Loop : ") for(let name of names){ console.log(name); }To download raw file Click Here
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions