<h3>debug</h3>
<p>当你已经厌烦于各种断点的时候,或者有的javascript代码chrome暂时无法格式化时,可以直接使用debug方法</p>
<pre><code>debug(ExampleApp.exampleFunction) </code></pre>
<p>这样每次<code>ExampleApp.exampleFunction</code>执行时都会自动断点。如果需要关闭,再调用</p>
<pre><code> undebug(ExampleApp.exampleFunction) </code></pre>
<h3>monitor</h3>
<p>如果只需要知道函数是否执行以及传入函数的参数,使用<code>monitor</code>和<code>unmonitor</code></p>
<h3>monitorEvents(object[, events])</h3>
<p>监控指定对象的相应事件,事件名可以是一个字符串,也可以是一个数组以监控多个事件,如</p>
<pre><code> monitorEvents(window, "resize"); monitorEvents(window, ["resize", "scroll"]) </code></pre>
<p>你也可以指定下述某一特殊类型事件,它们都对应一类事件</p>
<table> <colgroup> <col style="text-align:left;"/> <col style="text-align:left;"/> </colgroup>
<thead> <tr> <th style="text-align:left;">事件名</th> <th style="text-align:left;">匹配事件</th> </tr> </thead>
<tbody> <tr> <td style="text-align:left;">mouse</td> <td style="text-align:left;">“mousedown”, “mouseup”, “click”, “dblclick”, “mousemove”, “mouseover”, “mouseout”, “mousewheel”</td> </tr> <tr> <td style="text-align:left;">key</td> <td style="text-align:left;">“keydown”, “keyup”, “keypress”, “textInput”</td> </tr> <tr> <td style="text-align:left;">touch</td> <td style="text-align:left;">“touchstart”, “touchmove”, “touchend”, “touchcancel”</td> </tr> <tr> <td style="text-align:left;">control</td> <td style="text-align:left;">“resize”, “scroll”, “zoom”, “focus”, “blur”, “select”, “change”, “submit”, “reset”</td> </tr> </tbody> </table> <p>当需要取消监控时,调用unmonitorEvents(object[, events])</p>
<h3>$_</h3>
<p>返回最新一次表达式执行的结果 <img src="http://static.oschina.net/uploads/space/2014/0318/150348_eXRA_1471654.png" alt="在此输入图片描述" /></p>
<h3>$(selector)</h3>
<p>等价于document.querySelector(selector)</p>
<h3>$$(selector)</h3>
<p>等价于document.querySelectorAll(selector)</p>
<h3>$0 - $4</h3>
<p>chrome会记住最近5个你在tab或者Profiles panel中选中的dom元素,$0是当前选中的,$1是上一个选中的,以此类推。</p>
<h3>$x(path)</h3>
<p>根据xpath表达式选择元素</p>
<pre><code>$x("//p[a]") </code></pre>
<img src="http://static.oschina.net/uploads/space/2014/0318/150530_NBAX_1471654.png" alt="在此输入图片描述" />
<p>关于更多xpath的内容,可以<a href="http://www.w3schools.com/xpath/xpath_syntax.asp">参考w3c相关内容</a></p>
<h3>clear()</h3>
<p>不用多说,清空console</p>
<h3>copy(object)</h3>
<p>复制指定对象的字符串描述到控制台中</p>
<pre><code>copy($0); </code></pre>
<h3>dir(object)</h3>
<p>展示给定对象的属性信息,等价于console.dir() 下面代码展示了直接调用dir( document.body)和 document.body的区别</p>
<pre><code>document.body; dir(document.body); </code></pre>
<img src="http://static.oschina.net/uploads/space/2014/0318/150613_ZjmT_1471654.png" alt="在此输入图片描述" />
<h3>dirxml(object)</h3>
<p>类似于上述上面例子中document.body的展示信息</p>
<h3>inspect(object)</h3>
<p>比较有用的一个方法,可以直接定位到需要调试的元素,如在控制台中输入</p>
<pre><code>inspect(document.body.firstChild); </code></pre>
<img src="http://static.oschina.net/uploads/space/2014/0318/150632_YbMS_1471654.png" alt="在此输入图片描述" />
<h3>getEventListeners(object)</h3>
<p>返回指定对象绑定的事件结果为一个对象,对象每个属性为事件名,结果为一个数组,表示相应事件绑定的函数</p>
<img src="http://static.oschina.net/uploads/space/2014/0318/150645_IAoc_1471654.png" alt="在此输入图片描述" />
<h3>keys(object),values(object)</h3>
<p>返回指定对象所有属性或者属性值</p>
<h3>profile([name])和profileEnd([name])</h3>
<p>参考<a href="https://developers.google.com/chrome-developer-tools/docs/console#controlling_the_cpu_profiler">Controlling the CPU profiler</a></p>