为什么Google Chrome会通过jQuery输出不同的console.log()?

Zok*_*ora 14 jquery google-chrome console.log

当我控制登录jquery对象时,例如.

var s = $("#item");
console.log(s);
Run Code Online (Sandbox Code Playgroud)

我得到这样的东西

[div#item, context: document, selector: "#item", jquery: "1.9.1", constructor: function, init: function…]
Run Code Online (Sandbox Code Playgroud)

我记得之前(一个月前左右),我会得到类似的东西:

 [<div id="item">pas</div>]
Run Code Online (Sandbox Code Playgroud)

这是Chrome本身的变化吗?或者jquery有变化?或者我实际上做了一些让输出看起来不同的东西

我发现第二个输出更容易阅读,我可以将鼠标悬停在此页面上并将其标记在页面上.现在我得到太多的信息,这很难读

Bar*_*mar 1

我认为您注意到的是在控制台中评估 jQuery 对象与使用console.log(). 使用 David Thomas 的fiddle在语句上设置断点console.log。当它停在断点处时,$s在控制台中输入,您将看到

[<div id="item">pas</div>]
Run Code Online (Sandbox Code Playgroud)

然后继续,您将看到 打印的详细对象console.log()

我不太确定 jQuery 或 Chrome 正在做什么导致这种差异。键入时的输出$s似乎是 的结果$s.toArray(),而console.log()显示了真正的 jQuery 对象。

更多证据表明这不是新行为——我刚刚链接了 11 月份的一个重复问题。