In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how JavaScript converts non-logical values into logical values, which has a certain reference value, and interested friends can refer to it. I hope you can learn a lot after reading this article.
JavaScript Boolean object
Boolean (logical) objects are used to convert non-logical values into logical values (true or false).
You can think of a Boolean object as an object wrapper that produces logical values.
Create a Boolean object
Use the keyword new to define the Boolean object. A logical object named myBoolean is defined below:
Var myBoolean=new Boolean ()
If the logical object has no initial value or its value is 0,-0, null, "", false, undefined, or NaN
Then the value of the object is false. Otherwise, the value is true (even when the argument is the string "false")!
All of the following lines of code create a Boolean object with an initial value of false.
Var myBoolean=new Boolean (); var myBoolean=new Boolean (0); var myBoolean=new Boolean (null); var myBoolean=new Boolean (""); var myBoolean=new Boolean (false); var myBoolean=new Boolean (NaN)
All of the following lines of code create a Boolean object with an initial value of true:
Var myBoolean=new Boolean (1); [xss_clean] (myBoolean); [xss_clean] ("); var myBoolean=new Boolean (true); [xss_clean] (myBoolean); [xss_clean] ("); var myBoolean=new Boolean ("true"); [xss_clean] (myBoolean); [xss_clean] ("); var myBoolean=new Boolean (" false "); [xss_clean] (myBoolean) [xss_clean] ("); var myBoolean=new Boolean (" Bill Gates "); [xss_clean] (myBoolean); [xss_clean] (")
Check whether the logical object is true or false:
Var b1=new Boolean (0) var b2=new Boolean (1) var b3=new Boolean ("") var b4=new Boolean (null) var b5=new Boolean (NaN) var b6=new Boolean ("false") [xss_clean] ("0 is logical" + b1 + ") [xss_clean] (" 1 is logical "+ b2 +") [xss_clean] ("empty string is logical" + b3 + "") [xss_clean] ("null is logical" + b4 + ") [xss_clean] (" NaN is logical "+ b5 +") [xss_clean] ("string" false "is logical" + b6 + "")
Properties and description of Boolean object
Constructor: returns a reference to the Boolean function that created this object
Prototype: gives you the ability to add properties and methods to objects.
Boolean object method and description
ToSource (): returns the source code of the object.
ToString (): converts a logical value to a string and returns the result.
ValueOf (): returns the original value of the Boolean object.
Thank you for reading this article carefully. I hope the article "how JavaScript converts illogical values into logical values" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.