In javascript Creation phase and Execution phase. First phase is Creation phase.
In that phase create memory space for every variable and function that you write in your code.
So when the execution phase will run it can find it in memory.
And when the execution phase run it compile line by line and execute the code.Execution phase run single threaded Synchronous manner that means always execute single line at a time in order.