If you put all the script elements in the head element of the page, it means that you must wait until all the JS code is downloaded, parsed, and executed before you can begin rendering the contents of the page. For those pages that require a lot of JS code, there is a noticeable delay when the browser renders the page, and the browser window will be blank during the delay. To avoid this problem, the JS reference is generally placed behind the content of the page in the BODY element.
First, the basic concept
1, if the defined variable is to be used to hold the object in the future, it is better to initialize the variable to null instead of the other value. This allows you to know whether a variable of the response holds a reference to an object, as long as you check the null value directly.
2, for those large or small values, you can use the E notation (scientific counting method). 3.12e5<=>312000,3.12e-5<=>0.0000312. Floating-point numeric calculations produce rounding errors.
var a=0.2,b=0.1; a+b; // 0.30000000000000004
3, logic and logic or operators are short-circuiting operators (if the first operand can determine the result, the second operand is no longer evaluated)
var x=true;x&&y; // Error var x=false;x&&y; // false var x=false; x| | Y // Error var x=true; x| | Y // true
Use logical or short-circuit behavior to avoid assigning null or undefined values to variables
var a=null; var b=a| | {x:1};b; // Object {x:1}
4, the operator will convert the operand data.
' One ' > ' 2 '; // False, string comparison character encoding ' one ' >2; // true
When comparing strings, the actual comparison is the character encoding value for each character in the corresponding position of two strings. When you compare alphabetic strings in alphabetical order (<,>), you must convert two operands to the same case (uppercase characters are all smaller than lowercase letters)
5,js does not have a function overload, multiple functions with the same name, and a function that is defined later overrides the first defined function.
JavaScript Advanced Programming Reading notes