在Google Chrome控制台中查看所有JavaScript变量的列表 [英] View list of all JavaScript variables in Google Chrome Console

查看:3323
本文介绍了在Google Chrome控制台中查看所有JavaScript变量的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Firebug中,DOM选项卡显示所有公共变量和对象的列表。在Chrome的控制台中,您必须键入您想要探索的公共变量或对象的名称。



有没有办法 - 或者至少有一个命令 - 用于Chrome控制台显示一个列表中的所有公共变量和对象?这将节省大量的输入。

解决方案

这是您要查找的输出类型吗?

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

$ / code>

这将列出窗口 code> object(所有的函数和变量,例如 $ jQuery )等。虽然,这是一个列表,不知道这是多么有用......



否则只要做窗口和开始下去它的树:

 窗口

这会给你 DOMWindow ,一个可展开/可探测的对象。


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.

解决方案

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 it's tree:

window

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

这篇关于在Google Chrome控制台中查看所有JavaScript变量的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆