Paolo Paolo - 4 years ago 296
Javascript Question

Equivalent of Python's dir in Javascript

when I write Python code from the interpreter I can type

dir()
to have a list of names defined in the current scope. How can achieve to have the same information, programmatically, when I develop Javascript code from a browser using an interactive console like firebug, chrome console, etc?

Answer Source

There are a couple of functions which do just this in the code for ChatZilla, you'll have to check the licence properly to see if you can just rip them out and use them wherever.

The relevant functions can be found at http://hg.mozilla.org/chatzilla/file/59b46c0bf716/js/lib/utils.js#l136 dumpObject and dumpObjectTree

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download