What are all the values that ColdFusion considers “falsy” and “truthy”?

前端 未结 1 930
挽巷
挽巷 2021-01-21 12:56

I\'m looking to compile a complete list of values that ColdFusion considers falsy and truthy. The ones I know of are:

//falsy values
false
\"false\"
0
\"no\"

/         


        
相关标签:
1条回答
  • 2021-01-21 13:17

    There's a neat little article on that here http://www.coldfusionmuse.com/index.cfm/2010/2/5/Booleans.and.Coldfusion

    but of course officially it's http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec09af4-7fd0.html

    In Boolean expressions, True, nonzero numbers, and the strings “Yes”, “1”, “True” are equivalent; and False, 0, and the strings “No”, “0”, and “False” are equivalent.

    Boolean evaluation is not case sensitive. For example, True, TRUE, and true are equivalent.

    So, using your terminology:

    //falsy values
    False
    "False"
    0
    "No"
    
    //truthy values
    True
    "true"
    != 0
    "Yes"
    "1"
    
    0 讨论(0)
提交回复
热议问题