Javascript implementation of python’s dir command

The lack of an equivalent to python’s dir command in javascript annoys me, since it makes introspecting a chore.

Here is a quick implementation – terribly simple, but by putting it here I can avoid having to write it every day or so.

function dir(ob)
{
    out = [];
    for (attr in ob)
    {
        out.push(attr);
    }
    out.sort();
    return out;
}

Note that firebug already provides this function in its console.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


%d bloggers like this: