Deep understanding of Boolean object values and original values

Source: Internet
Author: User

The first is to understand the operator | | This is done: starting with a meaningful return from the first, or returning the last expression (note that it is not necessarily a Boolean value); && is doing this: starting with the first one, encountering a meaningless return, or returning the last expression (note ibid.);! This is done: take the value of the expression (note not the expression). Then try to look at the following code: var ob1 = new Boolean (false), var ob2 = (ob1&&true), var ob3 = (true&&ob1), var ob4 = Boolean (o B1&&true) var ob5 = Boolean (TRUE&&OB1), alert ("OB2 =" + Ob2 + "OB3 =" + ob3 + "OB4 =" + ob4 + "OB5 = "+ ob5); The result of the last Test is OB2 = True ob3 = False Ob4 = True OB5 = True

New Boolean (), new Boolean (false) is the same thing, because it is an object, it makes sense, but its value is false, so it can be seen as "meaningful false", so the result is the value of the last expression.


The original Boolean and Boolean objects are so different from each other, so keep in mind that they are different and don't confuse use.


a boolean object ,boolean object is an encapsulation of a Boolean value.
boolean object: A Boolean object with a value of true or false.


This problem is recently in the experience of a cow-guest app to do JavaScript topics encountered, and then query the information, and then general coding process we still do not write, so write not much significance, direct use of the original Boolean value can be, so it is difficult to write again understanding , it doesn't make much sense. But it's still possible to install X occasionally!

Deep understanding of Boolean object values and original values

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.