fe-interview
                                
                                
                                
                                    fe-interview copied to clipboard
                            
                            
                            
                        [jQuery] jQuery.fn的init方法返回的this指的是什么对象?为什么要返回this?
[jQuery] jQuery.fn的init方法返回的this指的是什么对象?为什么要返回this?
init()方法中返回的this指向init的实例对象,init.prototype=jQuery.prototype,是jQuery的实例对象。 返回this实现链式调用。
✂【回答】
jQuery.fn.init()方法中的 this 指向的是一个类数组对象,而不是指向的jQuery.fn。- this 指向 init 的实例对象,即 
$.fn.init.prototype,等于jQuery.prototype,也是 jQuery 的实例对象。 - 返回 this 是为了实现链式调用。
 
🖊【便签】
console.log($.fn.init() === jQuery.prototype);	// true
♡【关注】 https://blog.csdn.net/Hewes