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

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed