Tuesday 3 May 2011

JavaScript Object: Properties and Methods

Sometimes it needs to get list of Properties and Methods of the JavaScript Object. Its very easy to do with code like this::

var keysValues = "";
for(var keyName in myObject)
{
    keysValues += keyName + " = " + myObject[keyName] + ", ";
}
alert(keysValues);

This code shows list of all Properties and Methods of myObject.

Hope this helps!

No comments:

Post a Comment

Note: only a member of this blog may post a comment.