How to execute another function inside a function in JS

Source: Internet
Author: User
Tags call back

How to execute function b inside function a in 1.js

function A (parameter c) {

b ();

}

function B (parameter c) {

}

PS: In the case of the need to pass a parameter, the parameter C inside function A can also be passed into function B.

2. How to execute another function after 20 seconds

function A () {
SetTimeout (b,20000)
}
Function B () {
Alert ("20 seconds later Oh")
}

3. What is a callback function

A callback is a procedure that invokes a function. A callback, a callback, is the meaning of a call back. Function A is done in advance, and then the function B is called back.

Function A has a parameter, which is a function B, and executes function B after function a finishes executing. Then this process is called a callback.

How to execute another function inside a function in JS

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.