Lets see how.
for(prop in object)
Above structure shows how to apply “for in” structure on object.
How it works?
-Its start collecting all properties name to the left side variable (prop) with in the bracket.
var obj = new Object(); //Create new object
obj[“firstName”]=”vijay”; //Assign property firstName with value vijay
obj[“lastName”]=”khambalkar”;//Assign property lastName with value Khambalkar
var str=””; //variable which will hold property values
for(prop in obj)
str+=prop + ” value :”+ obj[prop]+”\n”;//Concate prop and its value from object
alert(str); //Show all properties and its value