Why console don't show methods of jQuery object returned from selector?

戏子无情 提交于 2019-12-02 12:30:51

The methods are on the prototype of the object. Both the console and console.log() do not, by default, show items on the prototype.

If you examine a jQuery object in the Chrome debugger, you can expand the prototype and can then see all the methods there.

So, what you are seeing is just the chosen implementation of the console. It shows direct instance properties, not items on the prototype.


When I put this code into a page:

function Person(){this.myProp = 'test'};
Person.prototype.proto = 'test2';

var person = new Person();
var jq = $("body");

And, then examine both person and jq in the Chrome debugger, I see this:

which shows the `proto property on both objects. And, if I expand that property for the jQuery object, it does indeed show all the methods.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!