Utilizor
Contact Us

For In Loop

Looping through properties.

Examples

Looping Object

Iterating over object keys.

const person = {fname:"John", lname:"Doe", age:25};
let txt = "";
for (let x in person) {
  txt += person[x] + " ";
}
console.log(txt); // John Doe 25

Looping Array (Not Recommended)

Iterating array indices.

const numbers = [45, 4, 9, 16, 25];
let txt = "";
for (let x in numbers) {
  txt += numbers[x] + "\n";
}

Test Your Knowledge

JavaScript Quiz

No quiz available for this topic yet.