Question : How to get a list of properties' names of a JavaScript object?

How to get a list of properties' names of a custom JavaScript object?
I can see the values of the object's properties using something like this:
for (prop in MyObject)
   alert(MyObject[prop]);
So the output will be like: "John Johnson", 22222, 25
But how to get names for those properties? They could be named like "Name", ID, Age, or they could be named differently?
I need to get an exact name of the property so I could access it directly, like this:
MyObject.<my_property_name>

Thank you!

Answer : How to get a list of properties' names of a JavaScript object?

Use : prop

test page :
1:
2:
3:
4:
5:
6:
7:
8:
<html><head></head><body>
<script language="javascript">
MyObject = { "Name":"John Johnson", "ID":22222, "Age":25 };
for(prop in MyObject) {
	alert( "value of propertie \"" + prop + "\" is : " + MyObject[prop] );
}
</script>
</body></html>
Random Solutions  
 
programming4us programming4us