need:
fun A() { asyn(parm1, parm2, onsuccess(){ }) ;}
fun B() {asyn(paem1, parm2, onsuccess(){}) ;}
Function B requires execution after function A
Asynchronous execution
If used directly
A();
B();
The execution conditions cannot be met.
Consider passing B as a callback function to A, and then A executes the B function in onsucess.
A(B);
Functional requirements can be realized.
js is single-threaded.
1. When calling a function, if there are more parameters than the number of definitions, the extra parameters will be ignored. If there are less than the number of parameters, the missing parameters will be automatically assigned an undefined value.
2. If the function definition is declared using the function statement, it cannot appear in a loop or conditional statement, but if the function definition is declared using the function literal method, it can appear in any js expression.
3. arguments object
The arguments object of a function is like an array, which stores the actual parameters when the function is called. You can use arguments[0], arguments[1], arguments[2]... to reference these parameters, even if these parameters are when defining the function. No. But arguments are not real array objects.
function a(x,y){
arguments[0] //Indicates the first parameter x
arguments[1] //Indicates the first parameter y
arguments[2] //Indicates the third parameter, provided that three parameters are passed in when calling the function
…
arguments.length //Indicates the actual number of parameters passed in
arguments.callee(x,y) //call itself}
The arguments object has a length attribute, which represents the number of parameters actually passed in when the function is called.
The arguments object also has a callee attribute, which is used to reference the currently executing function. This is especially useful in anonymous functions.
4. The length attribute of the function (yes, the function also has the length attribute)
Unlike arguments.length, the length attribute of a function represents the number of formal parameters when the function is defined, not the actual number of parameters when the function is called. You can use arguments.callee.length to call the length property of a function.