Delay script
HTML4.01 defines the defer property for the <script> tag. The script will be deferred until the entire page is resolved and then run.
Example: <script type= "Text/javascript" defer= "defer" scr= "Test1.js" ><script>
* Deferred scripts are not necessarily executed sequentially, so it is best to include only one deferred script
The Defer property applies only to external script files.
Strict mode
"User Strict"
Variable
Although it is possible to define global variables by omitting the VAR operator, this is not a recommended practice. Because defining global variables in local functions is difficult to maintain, and if the Var operator is deliberately ignored, it can cause unnecessary confusion because the variable is not immediately defined.
Type
There are 5 simple data types (also called basic data Types) in ECMAScript: Undefined, Null, Boolean, number and string, and a complex data type Object
typeof operator
The data type used to detect a given variable
typeof (Message) or typeof message * parentheses are not required
Undefined when declaring a variable with VAR but not initializing it, the value of this variable is Undefined
Null
If the defined variable is intended to be used for saving the object in the future, it is better to initialize the variable to null instead of the other value (because the null typeof value is Object)
*alert (null==undefined); True
Number
Leading 0 will be ignored, and subsequent values will be interpreted as decimal
If the floating-point number itself represents an integer (such as 1.0) then the value is also converted to an integer
NaN
A condition that represents an operand that would have returned a numeric value that did not return a number
Nan is not equal to any value, including the Nan itself.
IsNaN
Any value that cannot be converted to a number will cause this function to return true
numeric conversions
There are 3 functions that can convert a non-numeric value to a value of 1. Number () 2.parseInt () 3.parseFloat ()
The first function number () can be used for any data type, while the other two functions are specifically used to convert a string to a numeric value.
Number () If the value to convert is Underfine, return Nan
parseint () ignores whitespace in front of the string. If the first character is not a numeric character or a minus sign, parseint () returns Nan.
JavaScript Essays (1)