TypeScriptで条件分岐時の可読性の高い変数設定 – Qiita
const platform = (() => { if (game.name === 'ff3') { return 'fc'; } else if (game.name === 'ff4') { return 'sfc'; } return ''; })(); //—or const platform = (() => { switch (game.name) { case 'ff3': return 'fc'; case 'ff4': return 'sfc'; } return ''; })();
もっと詳しく