About Me

My photo
is a software engineer from bangalore.

Blog Archive

Friday, July 10, 2009

Getting the Properties and attributes of an object in Javascript

Hi fellas,
I was looking for a way to display all the
Properties and attributes of an object in Javascript.. Then this is what I ended up with.

function GetProperty(myObj) {
var temp = new Function();
var ArrayTemp = new Array();
for (myKey in myObj) {

if (typeof myObj[myKey] != typeof temp && typeof myObj[myKey] != typeof ArrayTemp) {

alert(myKey + " = " + myObj[myKey] );
}

}
}

When an object is passed as parameter to this method, All the Object properties will be popped as alerts...
It works.
Suggestions are always welcome.
Jacob....