Thursday, June 21, 2012

Java Script Tutorial 14 : JavaScript For .. In

The for  .. in statement loops through the properties of an object. Syntax of for .. in is as follow :


for (variable in object)
  {
        code to be executed
  }


For example


var person={fname:"waqas",lname:"ali",age:23}; 
for (y in person)
  {
       txt=txt + person[x];
  }


The result of above code will be


waqasali23

No comments:

Post a Comment