Special symbols && and | |

Source: Internet
Author: User

The case of a value of false

If the logical object value is 0,-0, Null,undefined,false, "", NaN. Then the value is false.

Second, && | | The understanding

1.&& when logic and && are found, a sub-item with false is stopped and the value of the sub-item is returned

2.| | When logic or | | , when a sub-item is found to be true, it stops processing and returns the value of the sub-item

1              var NULL False | | NaN  | | 3 | | 4;   32             alert (a); 3              var b = 4  new Object ()  null  && "0";   null4              alert (b);

Three, && | | The priority level

&& priority is higher than | |

1 alert (0 | | 1 && 2 | |-0); // 2

Four, commonly used code analysis:

function Test (options) {    var//{} Converts a Boolean value to True    //  If options is true returns options   true | | True returns the preceding true    //  If the options are false back {}  }

Special symbols && and | |

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.