JavaScript data type (top)

Source: Internet
Author: User
Tags uppercase letter

There are 6 types of JavaScript data:

    1. numeric data type (number);
    2. strings (string);
    3. Boolean data (Boolean);
    4. Objects (object);
    5. Null (NULL);
    6. Undefined (Undefined).

(a), number

var a = 12;alert (a);

The value of eject a is 12.

var a = 12;         

"typeof is the type of view variable. " the number that pops up is number, the return parameter of a is number, the type is number type" uppercase letter is data type, lowercase letter is the return parameter "

(b), String

var a = ' abc ';        alert (a);

The value of a pop-up is ABC.

var a = ' abc '; alert (typeof a);

The popup is a string, stating that A's return parameter is a string, and the type is of type string.

var a = ' 2 ' + ' 3 ';       alert (a);

The value of a pops up is 23, because at this point 2 and 3 are a string, that is, 2 and 3 are merged together.

var a = ' 2 ' + ' 3 '; Aert (typeof a);

The popup is a string, stating that A's return parameter is a string, and the type is of type string.

var a = ' 2 ' +3;        alert (a);

The value of a that pops up is 23.

var a = ' 2 ' +3; Alert (typeof a);

The return value is string, indicating that a is a string data type at this point.

var a = ' 2 ' +3+4+ ' 5 ';         alert (a);

The popup is also 2345, because it is in order, ' 2 ' +3 is a string, string plus 4 or string, String plus string ' 5 ' is finally a string. therefore for 2345.

var a = ' 2 ' + (3+4) + ' 5 ';         alert (a);

The value of a that pops up is 275.

var a = ' 2 ' + (3+4) + ' 5 '; Alert (typeof a);

The return value that pops up is string and is still a string data type.

var a = ' 2 '-' 1 ';         alert (a);

The value of a that pops up is 1. Because in JS, only the "-" string is subtracted.

var a = ' 2 '-' 1 '; Alert (typeof a);

The return value of the popup is number, which is the numeric value type.

var a = ' 2 '-1;         alert (a);

The value of a that pops up is 1.

var a = ' 2 ' -1;alert (typeof a);

The return value of the popup is number, which is the numeric value type.

(c), Boolean

var a = true;         alert (a);

The value that pops up is true.

var a = True;alert (typeof a);

The value returned is a Boolean. The description data type is a Boolean type.

Not finished ...

JavaScript data type (top)

Related Article

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.