I. Constructor call (with or without return)
1. var obj = new Object ();
var obj = new Object;
The two lines of code are equivalent; expression: New obj.m ();, this is not obj!!
The constructor is usually not used with the return keyword;
Two. Indirect calls
1. Call (), and apply (); Function: Any object can call any method/
Call ();--use its own arguments as arguments to the function;
Apply ();--to pass in an argument as an array;
2. Optional parameter: var a = a | | [];
3. Variable-length arguments: Arguments is a reference to an argument;
For example:
function Add (a,b,c) {
if (arguments.length! = 3) {
throw new Error ("The number of arguments actually passed in is:" + Arguments.length + ", but the function defines the number of formal parameters is 3!) ");
}else{
Return a + B + C
}
};
Add (1,1,2,9); Error: The actual number of arguments passed in is: 4, but the function defines the number of formal parameters is 3!
3. Function Add (a,b,c) {if (arguments.length! = 3) {throw new Error ("The number of arguments actually passed in is:" + Arguments.length + ", but the function defines the number of formal parameters is 3!) ");} Else{arguments[0] = Null;return A + B + c}}; Add (9,.); The result is: 3. "9" is set to "null" value;
4. Arguments in strict mode it cannot be assigned, and cannot be used as a reserved word for formal parameter names.
5.
201506170744_ JavaScript authoritative Guide (sixth edition)-function call variable length arguments and optional parameters, "(p171-175)