For In Loop in JavaScript

In JavaScript, the "" 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 "" loop is particularly useful when you need to access the keys or properties of an object and perform operations on them.

       for (variable in object) {
              // Code to be executed for each property of the object

Source Code

<!DOCTYPE html>
<html lang="en">
  <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>
	<script src="js/script.js"></script>
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

List of Programs

JS Practical Questions & Answers

JS Practical Project