3 ms·
Couldn't the browser simply internally turn this: function f1() { x = await fetch('something'); ... } Into this: function f1() {
by mg 2y ago
Couldn't the browser simply internally turn this:
function f1() {
x = await fetch('something');
...
}
Into this:
function f1() {
fetch('something').then(x => {
...
});
}
- the-lazy-guy 2y agoNo, it cant. These 2 are semantically not eqivalent, because in async version caller of f1() is resumed only once fetch has completed. In your callback version it will be resumed immediately. Also think how this should be translated: function f1() { x = await fetch('something'); return x + 1; }