Summary: implicit type conversion in Javascript, summary javascript Conversion

Source: Internet
Author: User

Summary: implicit type conversion in Javascript, summary javascript Conversion

JavaScript data types are divided into six types:null,undefined,boolean,string,number,object.objectIs the reference type, and the other five are the basic type or the original type.

For exampleNumber() , OrparseInt() ,parseFloat()All belong to the display type conversion (forced type conversion );

In this section, we will look at implicit type conversion (automatic conversion ).

The value is automatically converted to a string.

Var a = 123; alert (a + '20140901'); // output 456

"+" Is the connector

The string is automatically converted to a number.

Var B = 20; // alert (B-'10'); // subtraction output 10 // alert (B * 2 ); // output 40 by multiplication // alert (B/2); // output 10 by Division // alert (B % 2) // return output

Type conversion between "++" and "-"

Var c = '10'; c ++; alert (c); // output 11var d = '10'; d --; alert (d); // output 9

Type conversion of comparison Operators

Alert ('10'> 9) // output truealert ('10'> '9') // output false

Equal sign operator Conversion

Alert ('10' = 10) // output truealert ('10' = '10') // Output true

"!" Operator Conversion

Alert (! True); // outputs falsealert (! 100); // output falsealert (! 'Front-end web'); // outputs false

NaN is returned for conversions between other operators.

Alert ('web front-end developer'-10) // output NaN

The above is all the content of implicit type conversion in Javascript. I hope the content in this article will be helpful for your learning work. If you have any questions, please leave a message.

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.