2 ms·
The language provides Promise objects[0]. Async/await is just syntactic sugar around Promises - every await awaits a Promise object, every async returns one. A
by lucideer 3y ago
The language provides Promise objects[0]. Async/await is just syntactic sugar around Promises - every await awaits a Promise object, every async returns one.
Also, it's a bit weird to say callbacks -vs- promises. Callbacks aren't inherently async in themselves; there are some native async APIs that accept callbacks - the callbacks themselves are just functions, its the native APIs that are async. Also, Promises take and execute callbacks. We're still using callbacks.
What Promise objects did (for the first time) was give programmers the power to implement async functionality in the native language themselves, outside of native API calls to external functionality.
[0] https://tc39.es/ecma262/multipage/control-abstraction-objects.html#sec-promise-objects https://tc39.es/ecma262/multipage/control-abstraction-object...
- austin-cheney 3y agoDifferences between promises and callbacks is not the concern here. There are three options for asynchronous handling whether or not they are different under the hood and regardless if this is all just vanity. What Promise objects did Callbacks already did that. Its just moving one concern from an API to a method. Nonetheless the capability was already there natively in the language, which is called the event loop. In all things, even outside of code, people express vanity as an implicit means of advertising some manner of their identity or preferences. To the contrary people impose vanity on others only as a means of compensating for their own low confidence. Confidence is generally exceptionally low in software.