View list of all JavaScript variables in Google Chrome Console

GRboss picture GRboss · May 29, 2010 · Viewed 421.8k times · Source

In Firebug, the DOM tab shows a list of all your public variables and objects. In Chrome's console you have to type the name of the public variable or object you want to explore.

Is there a way - or at least a command - for Chrome's console to display a list all the public variables and objects? It will save a lot of typing.

Answer

Nick Craver picture Nick Craver · May 29, 2010

Is this the kind of output you're looking for?

for(var b in window) { 
  if(window.hasOwnProperty(b)) console.log(b); 
}

This will list everything available on the window object (all the functions and variables, e.g., $ and jQuery on this page, etc.). Though, this is quite a list; not sure how helpful it is...

Otherwise just do window and start going down its tree:

window

This will give you DOMWindow, an expandable/explorable object.