Hello, in this JavaScript video we are going to look at variable hoisting, and variable hoisting allows you to use a variable before anything even declared, we need to make sure that you assign something to it. But if you need to declare it at a later date, but you need to write the code to use it beforehand to be weird, but I'll show in a second. You can use this little method right here. So first of all, let me just show you something simple one equals 10. The console log, no. This will work as we expected the printed 10.
If however, I get this line cutter correctly for this line, we'll get an error undefined because my erase just undefined could not have not been defined, blinks dead. Instead of doing this. If we put num equal 10 So we'll start declaring after we're able to get the value, what would happen if we, you know, gotten rid of this? We'll get an error because nobody's not finally need to define it, especially now when we're using this use script tag, which I highly recommend, you know, encourages you to like good code analysis, that's all variable hoisting is. So it only works on declaration. So it only holds the declaration, not an initialization, so not when the value is set.
So we couldn't do this. However, for lambdas when it should still working. If I were to get this line right here, that's the same as just doing all of this in one line. As you can see, you'll still get undefined, but it only works. If you make sure you are trying to assign some value, B for it. That's variable hoisting you have any questions, feel free to pop me a message and I look forward to seeing you in the next video.