[2016-02-09] [JavaScript] [Data type coercion]

Source: Internet
Author: User

[2016-02-09] [JavaScript] [Data type coercion]

  • Similar to implicit conversions
    • Boolean () converts to a Boolean value
    • String () converts to strings
    • Number () is converted to a numeric type
  • parseint (String,radix)//Convert to integral type
    • String that needs to be converted.
      • String starts with 0, 8 binary
      • Start with a different number, 10 binary
      • 0x start, 16 binary
      • In other forms, the number legal part is read (similar to the C language when scanf reads int)
      • Note: You cannot convert bool to 0 | 1
      • Allow spaces at the beginning and end
      • cannot be converted to a number, return Nan
    • Redix binary, default 10-binary
    • parseint (0x123);//return 0x123 10 binary digits
    • Note: 2E3ASD reads 2000 instead of 2.
  • Parsefloat (string);//return conversion to floating-point type
    • Similar on parseint



From for notes (Wiz)



[2016-02-09] [JavaScript] [Data type coercion]

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.