JS logical operation

Source: Internet
Author: User

Non -!

Returns False if an operand is an object;

Returns true if an operand is an empty string;

Returns False if an operand is a non-empty string;

Returns true if an operand is a numeric value of 0;

Returns False if an operand is an arbitrary non-0 character;

Returns true if an operand is null;

Returns true if an operand is Nan;

Returns true if an operand is undefined;

Implicit conversion: ', 0,undefined,nan,false,null default conversion to FALSE! Time-varying to true

and &&

(1) For Boolean values, logic and is very simple, as long as there is a false, return false;

(2) For cases where the Boolean value is not true:

Returns a second number if the first operand is an object

If the second operand is an object, the object is returned only if the value of the first operand evaluates to true;

If the first two operands are objects, the second operand is returned

Returns null if one of the operands is null

If one of the operands is Nan, the first Nan is returned

Returns undefined if the first operand is undefined

or | |

(1) For Boolean values, logical or very simple, as long as there is a true, return true;

(2) For cases where the Boolean value is not true:

If the first operand is an object, the first operand is returned

Returns the second operand if the evaluation result of the first operand is false

If two operands are objects, the first operand is returned

Returns NULL if two operands are null

If two operands are Nan, a nan is returned

If two operands are undefined, the undefined is returned

JS logical operation

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.