JS Asynchronous operation callback function how to control the order of execution

Source: Internet
Author: User
Tags definition function definition

  This article explains the next JS asynchronous operation when the callback function to control the order of execution, interested friends can refer to the following

Requirements:  Fun A () {Asyn (Parm1, Parm2, onsuccess () {});}   Fun B () {Asyn (paem1, Parm2, onsuccess () {});}     function B requires execution after function A     Asynchronous execution   If the direct use of   a ();  B ();    is not able to meet the execution conditions.     Consider passing B as a callback function to a, and then a onsucess execution of B functions   A (b);    to achieve functional requirements.     JS is single-threaded .    1, when calling a function, if the argument is more than the number of definitions, the extra parameters will be ignored, if less than the number of definitions will be automatically given undefined value.   2, a function definition that is declared with a function statement may not appear in a loop or a conditional statement, but it can appear in any JS expression if it is a function definition with a function direct measure method.   3, Arguments object   Function arguments object is like an array, which holds the actual parameters of the function call, can be used arguments[0], arguments[1], arguments[2 ... To reference these parameters, even if they are not in the definition of the function. But arguments is not really an array object.   function A (x,y) {  Arguments[0]//Represents the first parameter x  Arguments[1]//Represents the first parameter y  arguments[2]//Represents the third parameter, The premise is that when the function is invoked, three parameters   ...  arguments.length//representing the actual number of incoming arguments   Arguments.callee (x,y)//calling itself}  are passed in. The arguments object has a length property that represents the number of arguments actually passed in when the function was called. The   arguments object also has a callee property that refers to the currently executing function, which is particularly useful in anonymous functions.   4, the length property of the function (yes, the function also has the length property)   andArguments.length, the Length property of a function represents the number of formal parameters when a function is defined, not the actual number of arguments when the function is called. You can use Arguments.callee.length to call the length property of a function.    
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.