for in loop is used to get object properties. properties are key value pair, for-in loop access, key and print or outputs its value.

Syntax

for (key in object) {
  // set of statements
}

Example

const car = {company:"Mahindra", name:"scorpio", make:2024, seats:7};

let detail = "";
for (let detail in car) {
  document.write(car[detail])
}