4 ms·
The difference is that when you call a function, you can easily know what will happen: the function will execute. You can use your knowledge about the function
by domenicd 10y ago
The difference is that when you call a function, you can easily know what will happen: the function will execute. You can use your knowledge about the function you are calling (and the functions it calls, etc.) to ensure it does not violate any invariants you set up.
Whereas, if you have an implicit yield point that goes back to the event loop, the event loop can run arbitrary other tasks---not ones you can locally reason about or predict, but simply those that are ready to be executed.
- gpderetta 10y agoBut if you know what a function does and call you would also know whether it is an implicit yield point or not, right? Also, I don't know about JS, but many event loops can be reentered recursively, so even with top level only yield all bets are off.