JavaScript variable type

Source: Internet
Author: User

Number Type

The number type represents a numeric type, including integral and floating-point types. JS in the long shape, short integer, single-precision, double-precision.

Number definition

The number type is defined as follows, the first of which is most commonly used. The latter two are generally not used.

var1;varnewNumber();  //初始值为0varnewNumber(1);

Number types are integral and floating-point

var1;    //整型var2.3;  //浮点
Infinity
    • is a numeric type
    • Represents a value that exceeds the JavaScript processing range
    • Any divisor divided by 0, also infinity
//在谷歌控制台中输入typeofInfinity"number"//--------------------------var6/0Infinity//但是直接使用 typeof 6/0 最后的结果是NaNtypeof6/0NaN
NaN
    • is also a numeric type
    • If the calculation fails, the result is Nan
    • Contagious, if there is a nan in the arithmetic operation, it causes the whole arithmetic to fail
//在谷歌控制台中输入typeofNaN"number"//--------------------------var6‘s‘NaN
typeof operator and typeof () function

typeof is used to determine the type of variable, usage:

var0vartypeof s;if(typeof‘number‘);typeof(s)

Here you only understand the usage of typeof

Note:
typeof is an operator and not a function, and typeof () is a function.

Undefined and null

Typically, when we access an unassigned variable, we get a undefined value.
Null means null and nothing.

JavaScript variable type

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.