In JavaScript, the "for...in" loop is a traditional iteration method used to loop over the properties of an object. It allows you to iterate through the keys or property names of an object, rather than the values. The "for...in" loop is particularly useful when you need to access the keys or properties of an object and perform operations on them.
Syntax:
for (variable in object) {
// Code to be executed for each property of the object
}
<!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 user = { name: "Tutor Joes", age: 35, city: "Salem", contact: "9043017689", }; for(let prop in user) { console.log(prop+" : "+user[prop]); }To download raw file Click Here
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions