JS Conversion Data type

Source: Internet
Author: User

JavaScript is a kind of dynamic data type language, the variable is not type, can randomly assign arbitrary value, if the variable to convert data type, there are two ways: implicit conversion
and an explicit conversion.

Implicit conversions can be converted to strings (adding a value to a string) number (using the plus operator before the value or using the minus, multiply, divide, modulo operators) Boolean values
(use non-in front of the value!) Operator two times)

Explicit type conversions (more important)
Force conversion to Digital
The parseint () function parses a string and returns an integer.

The parsefloat () function resolves a string and returns a floating-point number.

Number () function, you can convert any type of value into numbers.

Cast to String
String () function to convert any type of value into a string.

Cast to a Boolean value
Boolean () function, you can convert any type of variable to a Boolean value.
The conversion result for the following five values is false:undefined null 0 NaN "" and the other values are all true.

JS Conversion Data 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.