|
|
|
|
|
by brundolf
1780 days ago
|
|
> But what if you got it from an outside function, such as init(), and it was an object instead? Then you would have to guarantee that the return value of init() would not change between statements. Then even in a synchronous context you'd have no guarantee that it wouldn't be modified: function soSomethingSync() {
window.someObj.someProp = 12;
}
let x = window.someObj;
soSomethingSync();
console.log(x)
This has nothing whatsoever to do with sync vs async.It is one of the main reasons people like immutability/functional programming. But that's its own topic. |
|
Its a fundamental concurrency pattern used in a lot of languages, often for UI threads and such. There's a lot of information on this topic and it certainly is about async/yielding.