To answer your question, we need to shed light on how javascript executes code. Javascript follows the run to completion model, which pretty much means your code will reach the out4 console log no matter what (with an exception if you use async await in your code or an synchronous error occured etc.)
Javascript uses the single threaded model, so how does it deal with code execution?
To focus on your first question, we need to see how the task queue and microtask queue operates.
Those queues are basically feeding the event loop with things to do. So, in which order they get consumed? The event loop consumes messages by first executing the current task and then proceeds to execute all microtasks that may be introduced and so on and so forth (check the tasks vs microtasks topic).
So, what is a task and what is a microtask anyway?
A task is created everytime code is requested to run, setTimeout or setInterval is called, or an event is fired (for example user input event)
A microtask is very similar to a task, but they differ in the way they are created. Promises are basically using microtasks
To answer the first part of your question, there are two tasks. First task is to run this script. The second task that is enqueued is to fire the callback of setTimeout. Between those two tasks, two Promises (microtasks) are enqueued. All of the above result to the print order you see.
There is a great visualization of the above in this blog post, which I highly recommend to read.
As per your second question, then function may use a function reference as an argument