Best Way for Conditional Variable Assignment

后端 未结 12 1139
一个人的身影
一个人的身影 2021-01-31 02:26

Which is the better way for conditional variable assignment?

1st method

 if (true) {
   var myVariable = \'True\';
 } else {
   var myVariable = \'False\         


        
12条回答
  •  滥情空心
    2021-01-31 02:39

    Maybe you simply need && operator to check if boolean is true, if it is, assing "myVariable" to true.

    var myVariable = 'False';
    true && myVariable = 'True';
    

提交回复
热议问题