Block statement: {statement 1; Statement 2; Statement 3 ...} There is a function scope, global scope, value scope, no block-level scope var a=b=1:a is a local variable, B is a global variable
Try-catch statements
Try { try{ thrownew Error ("Opps"); }finally{console.log ("finally"); }}catch(ex) {Console.error ("outer", ex.message);}
The throw order is: finally,outer,oops;
Try { try{ thrownew Error ("oops"); } Catch (ex) { console.error ("inner", ex.message); } finally { Console.log ("finally"); } } Catch (ex) { console.error ("outer", ex.message);}
The throw order is: inner,oops,,finally; The exception is handled internally, so it is not thrown out to be processed.
. Try {try{thrownew Error ("oops");} Catch (ex) {Console.error ("inner", ex.message);} finally {console.log ("finally");}} Catch (ex) {Console.error ("outer", ex.message);}
The order of throwing is: Inner,oop,finally,outer,oops, internal exception is not processed need to go outside to deal with, before processing need to execute finally;
! The function () {} (1) indicates that it is a function expression rather than a function declaration, and the following (1) is passing the parameter 1 into the front! , which can be understood as a method of converting a function declaration into a function expression.!function () {} (1) is also equivalent to (function () {}) (1); It can also be replaced by A +,-such unary operators, all of which play the same role. A function is also an object, arguments is one of its properties, and the properties of the function include Name,length and so on. Arguments is the meaning of the Parameter object, without the need to write formal parameters on the function, you can get the arguments put in the function, use Arguments.length to get the number of arguments, arguments[0], to get the first argument.
Creating objects, new/prototype chains
function= 3; varnew foo (); obj.z; // 3 typeof obj.tostirng; // ' function ' in obj; // true; Obj.hasownproperty (' z '); //
obj.z=5; // If obj does not have z this attribute, add, some words will modify the value obj.hasownproperty (' z '); // true foo.prototype.z; // still 3 obj.z; // 5 obj.z = undefined; ojb.z; // undefined delete obj.z; // true to delete z obj.z on obj ; // 3
Object.create creating objects
var obj = object.create ({x:1}); obj.x; // 1 typeof Obj.tostring // "function" obj.hasownproperty (' x '); // false var obj = object.create (null); obj.tostring // undefined
When setting a property value, if the current object does not have this property, the property is looked up through the prototype chain. 1 if this property is defined by the Get/set method on the prototype, then both read and write will pass through the Get/set method only, in which case the property can only be added to the current object by Object.defineproperty. 2 If the prototype is a normal property assignment, then a property is added to the current object
Attribute Tags: do not define default to Falsevalue: Value writable: Modifiable enumerable: Enumerable for-in about configurable: deduplication related to delete
Methods for defining multiple properties at once: Object.defineproperties (obj,{Properties 1:{Property Tags}, Properties 2:{property tags}, ...} )
Object.preventextensions (): Sets the extensible label of the object to False, does not change the label of the object's properties, Object.seal (): Sets the extensible label of the object to False, The configurable tag for changing the properties of an object is False;object.freeze (): Sets the extensible label of the object to false, and the configurable label for the property of the object is false and writable The label is false;
JavaScript statements/Objects