我有一堆看起来像这样是否有可能这两个功能
'tea' : function (caller) {
this.speak(this.randomOption('tea_msg'));
},
'chill' : function (caller) {
this.speak(this.randomOption('chill_msg'));
},
,我想的是,将它们合并到这样的事情
'tea' ,'chill': function (caller) {
// get which function name was called in var lets call it fun
this.speak(this.randomOption(fun +'_msg'));
}
功能合并这是可能的还是我以这种错误的方式去做?
@Joachim绍尔感谢纠正我的文法/拼写 – mcgrailm