For..in loop in JavaScript

 For..in  loop in JavaScript 


In this article we are goanna to see about what is for..in loop and where we use these. which is most important when you are going to start your career in JavaScript. Please read and enjoy this article if you want to give any feedback about your experience, we welcome.




For..in loop is used to loop through an object’s properties.

Syntax:

for(var variable_name in object_name)
{
block of statements;
}

Ex:

for(var school in class)
{
document.write(school);
}

Ex:

var person = {fname:“Rajesh", lname:“kumar", age:25};


for (var x in person)
{
  console.log(person[x]);
}

Share:

0 comments

Please leave your comments...... Thanks