One, operator
1, unary operator:
Self-added self-reduction (2 types of front and rear): + + 、--
Difference: The first self-added or self-reduction, after the calculation, the second is the first to calculate, after the increase or decrease (in which it will have negative effects to reflect the difference);
var i=1; I+ +; // ++i // no negative effects in case: 2/2 var a = (++i) +i; var b = (i++) +I;console.log (a); // 6Console.log (b); // 7
It is suitable for any type, not a numeric type, to be converted to a numeric type number () ; (the literal of the underlying type cannot be used because it is immutable)
Add and Subtract operators: +,-
When its operand is not a number type, the operand is converted to number () type;
2, Bitwise operators:
Positive number: the original code representation;
Negative number: Complement expression (inverse code + 1);
Bitwise NON (~): negation code;
Bitwise AND (&): Both 1 is 1, the other is 0;
Bitwise OR (|): 1 is 1, both 0 is 0;
Bitwise XOR (^): At the same time 1, the difference is 0;
Shift Left (<<): vacancy 0;
Shift Right (>> sign bit): Empty fill sign bit;
Shift Right (>>> without sign bit): empty 0;
3. Boolean operator:
Logical non (!): Returns an inverse boolean value ;
Logic and (&&): Returns a Boolean value when both are Boolean values, not necessarily Boolean when there is not a Boolean value;
Logic or (| | ): Returns a Boolean value when both are Boolean values, not necessarily Boolean when there is not a Boolean value;
(Note: Logic and logic or both are short-circuiting operators )
4, Subtraction:
5, relational operators (>, >=, <, <=): are numeric, numeric comparisons, are string comparisons, and other conversions to a numerical comparison;
6, the equality operator (= =, = = =): Equal and congruent, congruent does not carry out type conversion;
7, three-wood operator (?:):;
......
Second, the statement:
1. If statement: Boolean () is converted to Boolean when the judging condition is non-boolean value;
2. Do-while: At least one cycle body is executed;
3. While:
4. For statement:
5. In statement: Used to enumerate object properties;
6. lable statement:
7. Break and Continue statements:
8. With statement: You can modify the scope to set the scope of the code to an object; with (...) { ... }
9. Switch statement:
3. Variables, scopes, and memory:
1. Value types and reference types: variables of value types hold specific values, whereas reference types are those that hold them;
2, the parameter of the function can pass only the value, so when the reference type is passed, its reference is passed;
3, the scope is defined when the non-call time;
function A () { var t="aa"; Function B () {Console.log (t); } return b; var t="ww"; var b=A (); B (); // AA is not WW
4, extend the scope chain: Try-catch catch block and with;
5, JS no block-level scope;
JavaScript second time Basic Learning notes (ii)