桥接模式 优化代码重复性
// 优化前
app.get = function(){}
app.post = function(){}
app.put = function(){}
// 优化后
var menthod = ['put','get','post'];
menthod.forEach(function(key){
app[key] = function(){
router[key].call(this);
}
})
// 优化前
app.get = function(){}
app.post = function(){}
app.put = function(){}
// 优化后
var menthod = ['put','get','post'];
menthod.forEach(function(key){
app[key] = function(){
router[key].call(this);
}
})