DEV Community

Discussion on: Syntactic sugar: yet another async/await question for JavaScript interviews

Collapse
 
mfulton26 profile image
Mark Fulton • Edited

I suggest avoiding the term "non-async" when explaining the problem. Async is short for asynchronous and a non-asynchronous function is a synchronous function and that is not what you mean. e.g. Although loopWithDelayNonAsync isn't an instance of AsyncFunction it is an "async" (commonly used in code as shorthand for "asynchronous") function as it returns a Promise (which represents the fulfillment of an asynchronous operation).

One simple way to avoid this ambiguity would be: "How would you go about implementing a state-machine-style version of the following async function without using the async/await keywords ..."

Collapse
 
noseratio profile image
Andrew Nosenko • Edited

I was actually contemplating how to avoid this ambiguity, but decided to stick with "non-async" for its literal meaning, no async modifier. Moreover, an asynchronous (in common sense) function doesn't even have to return a Promise, it can be any thenable. Anyhow, it's a great point, thank you. I agree I need to change the wording, and I think I'd also add "... without yield" :)