Flex converts string to boolean

Source: Internet
Author: User

The value is determined based on the true and false values configured in the configuration file in the.

 "false" as Boolean //flase"true" as Boolean //falseBoolean("flase") //trueBoolean("true")//true 

"False" as Boolean is flase

Is a string, not a boolean type, so it is false

Boolean ("flase") is true

Determines whether a string is empty without looking at the content.

Obviously, this is not an empty string

SetexpressionConvert the parameter to a Boolean value and return this value.

The returned value depends on the data type and value of the parameter, as described in the following table:

Input value Example Return Value
0 Boolean(0) false
NaN Boolean(NaN) false
Number (non0OrNaN) Boolean(4) true
Null String Boolean("") false
Non-Null String Boolean("6") true
null Boolean(null) false
undefined Boolean(undefined) false
Object class instance Boolean(new Object()) true
No Parameter Boolean() false

Because you do not want to write the if statement

Boolean(Number("0"));//falseBoolean(Number("1"));//true

But this is not intuitive.

If you want to determine whether there are only

If (STR = "true ")

There are many small problems with new technologies, so I will explore and learn more slowly.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.