One of the interesting features of JavaScript is it's asynchronous execution. Basically, what that means is it just runs as fast as it can. So let's say we have row 1, row 2, row 3, and row 1 does something locally. Row 2 makes a call out to some third party service, and even though it's fast, it takes a few seconds to return, or even a few milliseconds. Then we have row 3, and that also just does something locally, like log something console. Then what we're going to see happen almost certainly is that row 1 is going to execute, then row 3 is going to execute, and then we'll see the result of row 2 executing. So this is a feature of JavaScript that mostly makes sense under most circumstances, but can cause us problems if we want one event to only happen after another event happens. So looking at the case here, the first part of this appendix on key JavaScript concepts is this idea of asynchronous execution. I'm not going to really read through this part, it's beautifully written, but basically you can read through this and then there is a third party readings quite good here about the asynchronous executed JavaScript if you're interested. However, what I'm going do is just show you how this relates to some of the sample code. I think that'll be probably enough for this to make sense to you for current purposes and likewise extensions that you might want to make of this code for your project for example. So let's have a look at the sample code. One of the things that we're going to see is this thing where we have a dot then. So for example, what's happening is that we're saying do this firebase.auth.signOut. Most of these fire-based calls are going to be slow compared to the stuff that's running locally or out on JSFiddle. The reason is even though firebase is for the most part perfectly fast, just having to go out there and wait for a response is going to take awhile. So for example, when we want to log something into console or catch an error after that sign out and make sure that we return that properly the user well, then we need to use this then statement to basically change the event onto the sign out event. So what this code is saying here is, do the sign out, once the sign out is done, then, execute these other things, like I signed out the user, catch any kind of errors, and so forth. Otherwise, what might happen is that we might miss the error. If this code was separate, for example, we might have this thing returned. The code that's supposed to show the error to the user runs, it doesn't see an error so it just does nothing, and then this this whole thing doesn't work. So let's look at some other examples. Here's the sign in. What we want to have happen is once the user signs in, then basically, we want to clear the form. That's what this code is doing, or if there's an error, we want post that error off. Well, that's another place where the asynchronous execution of JavaScript requires us to make sure these two events are chained explicitly together, and firebase offer this with a response called a promise. So it's this promise that allows us to chain this then function onto this other event that's happening. So that's a little bit of a brief intro to the asynchronous execution of JavaScript, and how it relates to some of the code you're seeing, and why that code is necessary. How we're making sure that we get the right events happening in the right sequences.