Home > Article > Web Front-end > What are the rules for converting JS type values into Boolean types?
This time I will bring you the rules for converting JS type values into Boolean types, and what are the precautions for converting JS type values into Boolean types. The following is a practical case, let’s take a look. one time.
Due to the recent written examination, I found a lot of questions about converting other types into Boolean types, so I will summarize it! 1. Convert the##2. Convert Number type to Boolean
2. When the conversion result is false
②NaN
3.
Object class②Array object (including empty arrays)
③
Regular expression2. When the conversion result is false
PS: This should be distinguished from the previous empty object {}. An empty object means that the object has been created, but there is nothing in it, while an empty object means that it has not been created, which is a null
4. Convert Undefined type to Boolean
I believe I read this article You have mastered the case method. For more exciting information, please pay attention to other related articles on the PHP Chinese website!
Recommended reading:
How to use JavaScript stringsHow to implement two-way data binding in WeChat appletThe above is the detailed content of What are the rules for converting JS type values into Boolean types?. For more information, please follow other related articles on the PHP Chinese website!