我对 jquery 1.7.3 source 中的“this”关键字感到非常困惑。下面显示的一些片段:
jQuery.fn = jQuery.prototype = {
constructor: jQuery,
init: function( selector, context, rootjQuery ) {
var match, elem, ret, doc;
// Handle $(""), $(null), or $(undefined)
if ( !selector ) {
return this;
}
// Handle $(DOMElement)
if ( selector.nodeType ) {
this.context = this[0] = selector;
this.length = 1;
return this;
}
if ( !selector ) {
return this; //why not only one "return" here?
//And does "this" refer to jQuery object?
//OTOH, this question is about why it returns "this".
}