📜  功能不是 if then else - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:26.205000             🧑  作者: Mango

代码示例1
//remove if then else...

OBJECT  MAPPER
const colors = { red: true, blue: true, 'default': false, };         //An object specifying the results
const colorMapper = color => colors[color] || colors['default'];    // A mapping function
const color = colorMapper(item.color);