JS Number Type

Source: Internet
Author: User

Number: Positive, negative, 0, decimal, NaN

Nan:not A number is not a valid digit but he is a numeric data type of

var num = 12;

12==12 comparison

var a= 12 Assignment;

IsNaN (); detects whether a value is a valid number if the proposition is true, is a valid number that returns FALSE, is not a valid number to return;

If the detected value is not of type number, the browser will default to convert it to type # and then determine if it is a valid digit

Console.log (IsNaN ("123")) returns the result is False

First convert "123" to Number = Number = number ("123")

Number () forces other data types to be converted to type #, which requires numbers in a string to be converted if they are strings

Number ("==>12") Number ("12px") ==>nan

Non-mandatory data type conversion parseint/parsefloat

Console.log (parseint ("12px"));

From left to right, a character search, the number is converted to a valid number, midway if you encounter a non-valid number, will not continue to find

Parsefloat () ibid.

JS Number 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.