标签: javascript conditional-statements ternary-operator
以下JavaScript布尔三元表达式是否有简写语法:
var foo = (expression) ? true : false
答案 0 :(得分:5)
当然,您只想将表达式转换为布尔值:
var foo = Boolean(expression);
或the same thing缩短为double not operators:
var foo = !! expression;