(function(){
var _jQuery = window.jQuery,
_$ = window.$;
//==========================0.0.1=====================================
// var version = '0.0.1',
// jQuery = function(selector){
// console.log(document.querySelector(selector))
// };
// jQuery.prototype={
// jquery:version,
// constructor:jQuery
// }
//抽出构造函数
// function Factory(selector){
// return new jQuery(selector);
// }
// Factory.fn = jQuery.prototype;
// Factory.extend = Factory.fn.extend = function(){
// console.log(this)
// }
// window.$ = window.jQuery = Factory;
// ================================0.0.2================================
var version = '0.0.2',
jQuery = function(selector){
return new jQuery.fn.init(selector)
};
jQuery.fn = jQuery.prototype={
jquery:version,
constructor:jQuery
};
var init = jQuery.fn.init=function(selector){
if(!selector){
return;
}else{
var elem = document.querySelector(selector);
if(elem){
this[0]=elem;
this.length=1
}
}
}
init.prototype=jQuery.fn;
jQuery.extend = jQuery.fn.extend = function(){
console.log(this)
}
window.$ = window.jQuery=jQuery;
})()
console.log($.fn.jquery)
console.log($('.box'))
<div class="box">
</div>