1. Short Circuit logic
In a logical operation, if the previous condition can already draw the final conclusion, all subsequent conditions are no longer executed! The logical operation here refers to logic and logic or.
We have to understand that the logic and the two conditions are true, it is true, if the first one is false, then the next one will not be executed. Logic is not one of the two conditions is true, then the result is true, so as long as the first is true, then the result is true, the following statement will not be executed. Then the following example:
Console.log (2&&3); // 3console.log (2| | 3); // 2Console.log (0&&1); // 0console.log (0| | 1); // 1
2. Passing by value
When assigning or passing a parameter to a function between two variables, the value of the original variable is copied to the other, modified one, and the other does not change. (This is to be likened to Voldemort's seven Horcrux, but do not know that every destruction of a Horcrux, Voldemort will be affected?) Harry Potter brain Remnant powder. )。
var a = ten; var b = a;a+ +; Console.log (b) ; // Ten
But the value of the reference type is passed, only the reference address is passed, so one of the values is changed, and the other one changes. It was like a room with two keys, one opening the door, taking all the money, and the other key opening the door, the money was gone.
var a=[1,2,3,4]; var b=A;a.pop (); Console.log (b); // the
3. function declaration in advance
All Var-declared variables and function-declared functions are centrally declared at the top of the current scope prior to the formal execution of the program. But the assignment stays in place.
functionreturn 1; } Console.log (Fun ()); // 2 function return 2; } Console.log (Fun ()); // 2 var fun=100; Console.log (Fun ()); // Error
JavaScript Novice Learning Notes 4--I can't remember a few pits: short-circuit logic, passing by value, declaring ahead