JS logic is not used at the same time two times!! Null

Source: Internet
Author: User

Today met "!! Null ", Baidu did not find a direct explanation, the book in the" Advanced design of JavaScript "P44 found the corresponding explanation:

Using two logical non-operators, in effect, simulates the behavior of a Boolean () transformation function. Where the first logical non-operator returns a Boolean value based on whatever operand, and the second logical non-operation evaluates the Boolean value, the Boolean value that the value really corresponds to is obtained. Of course the end result is the same as using the Boolean () function for this value.

So actually personally think,!! The notation is a simple notation for Boolean ().

You can run the following example to see more visually:

Alert (!! " Blue "); Alert (Boolean (" Blue ")); Alert (!! NULL); alert (Boolean (null));

  

If you have any mistake, please indicate ~

JS logic is not used at the same time two times!! Null

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.