I understand that into a jQuery callback $(this)
passes a reference to a DOM object (or array of objects) to jquery and constructs a jquery object and I also understand that this is the reference to the DOM object (or array of objects) the jQuery selector selected, but I don't understand why those two different objects have the same jQuery methods in the Chrome inspector:
// Print the object methods (found here on stackoverflow)
function getMethods(obj) {
var result = [];
for (var id in obj) {
try {
if (typeof(obj[id]) == "function") {
result.push(id + ": " + obj[id].toString());
}
} catch (err) {
result.push(id + ": inaccessible");
}
}
return result;
}
...
// into a jquery callback
console.log(getMethods($(this))); // This returns an array of jQuery methods
console.log(getMethods(this)); // This does the same - why??
Edit: this is what I see in Google Chrome (latest release at the time of writing this):