Implicit type conversion of JavaScript

Source: Internet
Author: User

First, a simple understanding of JS typeof, will return six types

That is, number string Boolen function object undefined is also six basic data types

There are probably several types of display type conversions:

  Number () is converted to number type

  string () is converted to string type

  Boolean () converts to Boolean type

And so on tosting () paseint ( ) and other methods, need to say again is parseint ()

  When you enter parseint (' 3242SFDA ') will return 3242

But input parseint (' sfda3242 ') returns Nan

That is, if the first character is not a number, Nan is returned, and it is important to note that the online tutorial also mentions

Implicit type conversions

  Implicit type conversions are implicitly invoked when some operations are performed, such as Nmuber, as follows:

 + Call string () when there are stirng types on both sides

  > < >= <= = = = # call number when both sides have number type ()

  && | |   ! Call Boolean ()

  ++/--+/-/*/% call number ()

  IsNaN () call number ()

  = = = does not call

Above personal feeling the most important is the first two ,+ need to explain in a moment

The default is to call number (), but it detects if there is a string on both sides, and some uses string directly, but

Direct console input +string will return Nan can try to enter + ' ADFAA ' in console

Personal study records, if not, please correct me.

Implicit type conversion of JavaScript

Related Article

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.