Get all Javascript Variables?

For Firefox, you can see the DOM tab -- easy, though not an answer to your question.

The for in loop provided in Kinopiko's answer will work, but not in IE. More is explained in the article linked below.

For IE, use the RuntimeObject.

if(this.RuntimeObject){
    void function() {
        var ro = RuntimeObject(),
            results = [],
            prop;
        for(prop in ro) {
            results.push(prop);
        }
        alert("leaked:\n" + results.join("\n"));
    }();
}

See also:

  • Detecting Global Pollution with the JScript RuntimeObject (DHTML Kitchen article)
  • RuntimeObject (MSDN docs)

Flanagan's "JavaScript - The Definitive Guide" gives the following on page 653:

var variables = ""
for (var name in this)
    variables += name + "\n";