JavaScript三元运算符嵌套使用

第一种嵌套情况

false?'true':true?'t':'f'  //t

 

false?'true':false?'t':'f'  //f

第二种嵌套情况

true?true?'a':'b':'c'  //a

 

true?false?'a':'b':'c'  //b

 

false?false?'a':'b':'c'  //c
var display_state = (state == null ? "未用" : (state == true ? "在用" : "停用"))
posted @ 2022-01-11 18:05  拨云丶  阅读(841)  评论(0编辑  收藏  举报