How is jQuery's $ a function and an object?

前端 未结 8 824
名媛妹妹
名媛妹妹 2020-11-29 08:22

I mean object as in {} [object Object]. How does it do $(selector) and $.fn.init at the same time?

Can you give me a simple ex

8条回答
  •  执念已碎
    2020-11-29 08:43

    var s = function(){};
    s.test = function(){console.log('inside s');}
    s.test();
    

    is perfectly legal code.

提交回复
热议问题