For example:
WITHOUT CALLBACK
function databaseQuery() {
// A database query is run which let's say take 20 seconds
x();
}
function x() {
console.log("Hello world");
}
WITH CALLBACK
function databaseQuery(callback) {
// A database query is run which let's say take 20 seconds
callback();
}
function x() {
console.log("Hello world");
}
databaseQuery(x);
FYI: I know there can be some factors like scope and other things but is there any SOLID functionality //that callback gives?
I tried Callbacks and normal function but got same result.
Via Active questions tagged javascript - Stack Overflow https://ift.tt/qh68n5x
Comments
Post a Comment