Javascript 三元布尔值 shorthand
Javascript ternary boolean shorthand
是否有以下 JavaScript 布尔三元表达式的 shorthand 语法:
var foo = (expression) ? true : false
当然,您只想将表达式转换为布尔值:
var foo = Boolean(expression);
或the same thing shortened to double not operators:
var foo = !! expression;
是否有以下 JavaScript 布尔三元表达式的 shorthand 语法:
var foo = (expression) ? true : false
当然,您只想将表达式转换为布尔值:
var foo = Boolean(expression);
或the same thing shortened to double not operators:
var foo = !! expression;