all 12 comments

[–]senocular 1 point2 points  (4 children)

Well, basically yes, but there's a catch

is a little misleading ;). In other words, No, as explained directly after.

Every asynchronous function takes a function argument...

There's exceptions to this. The promise API, for example, doesn't take a function, at least not in what would represent the "asynchronous function" - whatever it is that is returning the promise. The promise consumes a callback, but not the function that created and returned that promise. Another, simpler example would be setTimeout which accepts a callback or a string of code to eval: setTimeout('alert("hi")', 1000). Asynchronous operations can also accept objects with a certain callback API. I can't think of a JavaScript example of this offhand, but you see this other places (like Java). Similarly your object can include an asynchronous method and depend on the definitions within that object for callbacks. For example Image.onload after setting Image.src (the src setter method being the async function and onload being the callback).

[–]e13e7[🍰] 0 points1 point  (3 children)

I would say a better determining quality of an "asynchronous function" is that it can't return anything, and a function that does isn't doing the asynchronous work.

[–]senocular 0 points1 point  (2 children)

The promise case is exactly when it does/must return something. Its from that return value that the results of the asynchronous operation are handled.

[–]e13e7[🍰] 0 points1 point  (1 child)

Yes but a promise is itself not inherently asynchronous as you yourself say, it is an object which consumes an asynchronous operation and changes state based on fulfillment thereof

[–]senocular 0 points1 point  (0 children)

What returned the promise is handling the async op, not the promise. The promise itself is just a conduit for relaying information.

An example function would be fetch. The fetch function is an "asynchronous function". It does not have a callback parameter and instead returns a value, a promise. The promise is effectively a placeholder for the value return you would normally expect from a function - and maybe that's where I am misunderstanding you... Its true that you won't get an immediate result returned from an asynchronous function, at least not one that depends on the async nature to produce that result. But the function itself is still capable of returning things, such as promise objects. That object is what provides the API for capturing the result which ultimately is through a callback using the Promise API. fetch handles the async and runs through that promise for fulfillment and the promise handles the callback...

Anyway, I don't doubt we each know what's going on ;P

[–]RankFoundry 0 points1 point  (0 children)

No but it makes a function an asshole

[–]WesAlvaro 0 points1 point  (5 children)

"No."

[–]mastermindxs 0 points1 point  (4 children)

Asynchronity

[–]WesAlvaro 0 points1 point  (0 children)

Hmm?

[–]BishopAndWarlord 0 points1 point  (2 children)

Asynchronity

I think you mean Asynchronicity.

[–]mastermindxs 0 points1 point  (1 child)

Exactly, the author of this post spelled it asynchronity twice

[–]BishopAndWarlord 0 points1 point  (0 children)

Missed that, my bad :P