"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