<script>
var arr = function(){
return new arr.prototype.init();
}
arr.prototype.init = function(){//介质
return this;
}
arr.prototype.ded1 = function(){
console.log(1);
return this;
}
arr.prototype.ded2 = function(){
console.log(2);
return this;
}
arr.prototype.init.prototype = arr.prototype;
arr().ded1().ded2();
</script>
arr.prototype.init.prototype = arr.prototype;关键步骤
(function(){
var jQuery = function(){
return new jQuery.fn.init();
}
jQuery.fn = jQuery.prototype = {
constructor : jQuery,
init : function(){
return this;
},
say : function(){
console.log('say:hello');
return this;
},
tell : function(){
console.log('tell:hello');
return this;
}
}
jQuery.fn.init.prototype = jQuery.prototype;
jQuery().tell();
jQuery().say();
console.log( jQuery() );
console.log( jQuery.fn );
console.log( jQuery.prototype );
})()