Boolean Type in javascript

Source: Internet
Author: User
Boolean can be said to be the simplest type. I encountered some problems when using only the true and false values. Note: 1. newBoolean (false) Example 1: viewplaincopytoclipboardprint? 1. varexistsnewBoolean (false); 2. alert (exists? True: false );

Boolean can be said to be the simplest type. I encountered some problems when using only the true and false values. Note: 1. new Boolean (false) Example 1: view plain copy to clipboard print? 1. var exists = new Boolean (false); 2. alert (exists? 'True': 'false ');

Boolean is the simplest type, with only true and false values.

I encountered some problems during use. Note the following:

1,NewBoolean (False)

Example 1:

View plaincopy to clipboardprint?

1. var exists = new Boolean (false );

2. alert (exists? 'True': 'false ');

Var exists = new Boolean (false); alert (exists? 'True': 'false ');

The code above is shown :'True', That is, new Boolean (false) is true in condition judgment!

According to the information, the condition for determining the Boolean type is as follows:

1. All objects are considered to beTrue.

2. the string is considered to beFalse.

3. null and undefined are considered to beFalse.

4. if and only if the value is zeroFalse.

Well, now I understand,Typeof newBoolean (False) = 'Object', which is an object type. The first object based on the judgment condition isTrue

2. $ ('button1'). disabled = 'false'; invalid

Example 2:

View plaincopy to clipboardprint?

1. this. disabled = 'false ';

This. disabled = 'false ';

Example 3:

View plaincopy to clipboardprint?

1. this. disabled = false;

This. disabled = false;

Like above, 'false' is actuallyTrueThe second "string is considered to beFalse

SetTimeout ("submits ()", 5000); // latency Processing
SetInterval ("submits ()", 5000); // loop Processing

Original address:

Http://blog.csdn.net/zswang/archive/2009/02/24/3932586.aspx

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.