In the first example, invocation of
settingsDataAvailable(...)
occurs at minimum one microtask later due to the presence of an await
. This means that the synchronous top-level evaluation of the entire script will have completed before that invocation is reached. In your second example you are merely attempting to synchronously reference an identifier inside its temporal dead zone.