js设计模式之状态模式

来源:互联网 发布:php按值删除数组元素 编辑:程序博客网 时间:2024/06/06 18:55
var ResultState = function(){
var States = {
state0:function(){
console.log('first');
},
state1:function(){
console.log('second');
},
state2:function(){
console.log('third');
},
state3:function(){
console.log('four');
}
}
function show(result){
States['state'+result] && States['state' + result]();
}
return {
show:show
}

}();


ResultState.show(3);

0 0
原创粉丝点击