callback

Linda Hamilton
Linda HamiltonOriginal
2025-01-05 17:13:461022browse

callback

Callback Explanation:

What is a Callback?

A callback is a function passed as an argument to another function
It allows you to pass a function that will be executed after the first function completes
Helps manage the order of execution in JavaScript

function doHomework(subject, callback) {
    console.log(`Starting ${subject} homework`);
    callback();
}

function finishHomework() {
    console.log("Homework is done!");
}

doHomework("Math", finishHomework);

The above is the detailed content of callback. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn