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.

Leave a comment

Trackback this post  |  Subscribe to the comments via RSS Feed