JS Advanced Programming Supplements

Source: Internet
Author: User

"JavaScript Advanced Programming (Third edition)" repeatedly looked at many times, this review as the last of the first half of 2017, will all vague, remember the place to record, convenient for later consolidation.

0. <script> element Properties

Async means download Footsteps now, but should not interfere with other actions on the page;

Defer indicates that the delay is deferred until the document is fully parsed and displayed. Both of these properties apply only to external footsteps, and in reality the footsteps are not necessarily executed sequentially. The purpose of specifying the async attribute is to not allow the page to wait for download and execution.

It is best to include only one delay script, and it is still the best option to put the deferred script at the bottom of the page.

1.Number type

1.1 Nan is a non-numeric value that can be determined with isNaN (). IsNaN () When a value is received, attempts to convert the value to a number, and any value that cannot be converted to a number will cause IsNaN () to return true.

Alert (IsNaN (NaN))     //truealert (IsNaN ("ten"))   //falsealert (IsNaN (" Blue "))    //true

1.2 Numeric conversions

The isNaN () mentioned in the example above converts the value to a number, which is how it is converted. JS all numeric conversions, by default, are called by the number () transformation function.

Number (), parseint (),parsefloat () difference: The numbers () parameter can be any data type, and the last two arguments can only be strings (parseint () and more than one parameter of the conversion cardinality);

Number () returns 0 for the empty string, and the latter two returns Nan, because parseint () returns Nan for the first character, not a numeric character or minus sign, and number (), which requires that the string contain only numbers to be converted to numeric values, for the argument is a string.

The empty string goes to 0, otherwise it is converted to Nan, and then two functions are not required.

  

JS Advanced Programming Supplements

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.