【发布时间】:2019-05-04 19:13:02
【问题描述】:
问题
我正在尝试使用基于另一个变量的字符串值的条件运算符为变量赋值。
代码
const test = fnUserPlatform.platform === ('ps4' || 'xb1' || 'pc') ? 'p2.br.m0.weekly' : 'br.defaultsolo.current';
当 fnUserPlatform.platform 等于“ps4”时,测试正确评估为 p2.br.m0.weekly,但当 fnUserPlatform.platform 为“xb1”或“pc”时,它评估为“br.defaultsolo.current”,这是不正确的。
有谁知道为什么要这样评价?
【问题讨论】:
-
你能发布你的函数吗?
标签: javascript conditional-operator