jQuery 链式实现原理
var aQuery = function(selector){ return (new aQuery.prototype.init(selector)); } aQuery.prototype ={ init:function(selector){ this.selector = selector; return this; }, name:function(){ return "aQuery's name" }, age:10 } aQuery.prototype.init.prototype = aQuery.prototype; var m1 = aQuery("mery"); var m2 = aQuery("melin"); console.log(m1); console.log(m1.age); console.log(m1.name); console.log(m2); console.log(m2.age); console.log(m2.name);
http://www.cnblogs.com/xmyun/