From the course: JavaScript: Functions

Unlock the full course today

Join today to access over 23,400 courses taught by industry experts.

Hoisting and scope

Hoisting and scope

- [Instructor] We need to talk about one of the more interesting parts of JavaScript. It has to do with scope. So let's take a look at how that works and specifically, how it works with functions. Now, this is going to require a good understanding of how variables work. So if you want a great and fun explanation, make sure you watch this video in my course called JavaScript As A Second Language. Now, most of the time, scope refers to where a variable is available once it's been declared. And I'm talking specifically about how variables' declaration are done with the var, let and const keyword. Watch the video from JavaScript As A Second Language but basically, never use the var keyword. As we'll see soon, however, functions also have scope. So let's take a look at what happens when use the variable keyword, not because I want you to ever use it, but because you're probably going to run into some code that does use it…

Contents