for in loops javascript

JavaScript
function myFunction() {
  var person = {fname:"John", lname:"Doe", age:25}; 
  
  var text = "";
  var x;
  for (x in person) {
    text += person[x] + " ";
  }
}//this loops through an array, 'cars', and logs each element to the console.
for (var i = 0; i < cars.length; i++) {
  //repeating code here:
  console.log(cars[i]);
}var i;
for (i = 0; i < cars.length; i++) {
  text += cars[i] + "<br>";
}for (i = 0; i < 5; i++) {

   text += "The number is " + i + "<br>";

}

  
Source

Also in JavaScript: