JavaScript number types

Source: Internet
Author: User
The number type of JS

JS has only one type of number, and all the numbers in the number.js are of this type. Include integer 1,-2,3, floating-point number 1.1,-1.2,1.3 belong to this type. So, in JS, the typof integer or TYPOF floating-point number returns number.

Type conversion of JS

There are three commonly used functions in JS to convert non-numeric types to numeric types, number (), Parseint,parsefloat (), and can be lowered directly in the window scope, using:

Anumber = number (Notnumber);

AInt = parseint (Notnumber);

Afloat = parsefloat (Notnumber);

From the function name, you can see the function to:

Number (): You can convert non-numeric to numeric, the result may be an integer, or it may be a floating-point

parseint (): Convert a non-numeric type to a number, convert the result to an integer, direct rounding, no rounding operation

Parsefloat (): Converts a non-numeric type to a numeric type. The conversion result is a floating point number.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

JavaScript number types

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.