基本用法
三元运算符是在表达式中编写if-else的紧凑方法。
const thing = (condition) ? <if true> : <if false>;
例如
const cappedInput = input > 50 ? 50 : input // this will cap the input at 50
否则,如果
你也可以链接三元运算符,这样你就会有一个if-else if-else行为
<first condition> ? <value if first true>
: <second cond...