设计模式

Posted 且听风吟V

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了设计模式相关的知识,希望对你有一定的参考价值。

1.单例

var singleton = {
        attr : a,
        method : function(){ 
         return this.attr; 
        }
}

2.策略模式

let strategies ={
    "S":function(salary){
       return salary*4      
    },
    "A":function(salary){
        return salary*3     
     },
    "B":function(salary){
        return salary*2     
     },

}

 

以上是关于设计模式的主要内容,如果未能解决你的问题,请参考以下文章