How do I access properties of a javascript object if I do not know the names
For example we have object like blow:
var data = { Name: 'rohit', Value: '0' };
Properties can be accessed by the property name like below
data.Name
data["Value"]
Now we want to view all properties of Object, then we will write
for (var key in data) { alert(key); } or same can be achieve with below function:
for each (var value in data) { alert(value); }
http://
http://
Contributed by:
Rohit kakria
I am software developer
Resourse address on xpode.com
http://www.xpode.com/Print.aspx?Articleid=597
Click here to go on website
|