模仿JQ實現函數鏈式操作
// 字面量寫法
var obj={};
obj.a=function(){
console.log("a");
return this;
};
obj.b=function(){
console.log("b");
return this;
};
obj.a().b();
// 原形鏈寫法
var JQ = function(){};
JQ.prototype = {
show:function(){
console.log("show");
return this;
},
hide:function(){
console.log("hide");
return this;
}
};
var jq = new JQ();
jq.show().hide();

浙公網安備 33010602011771號