Executing the below using node - 6.0.
function A(callback) {
console.log(\'A\');
callback();
}
function B() {
console.log(\'B\')
}
f
No, neither of these is zalgo. Your first A
function always calls its callback synchronously, and should be documented as such. Your second A
function always calls its callback asynchronously, and should be documented as such. Nothing is wrong with that, we use thousands of these every day. The outputs A C B
and A B C
are deterministic.
Zalgo refers to the uncertainty whether a callback is asynchronous or not.
function A(callback) {
console.log('A');
if (Math.random() < 0.5) {
callback();
} else {
process.nextTick(callback);
}
}
The output of the invocation A(C); B();
would be totally unpredictable.