直接上代码、
const isColor = new Map()
.set('red',function(colorRed){
// 条件成立执行
console.log(colorRed); // 红色
}) .set('blue',function(){
// ...
}) .set('pink',function(){
//....
})
function test(color){
return isColor.get(color) || ''
}
test('red')('红色');