- [Instructor] In JavaScript there are
a few different types of scope, local, global
and block scope.
We'll explore each one in depth with code examples
but, in short, local scope is when a variable object
or function is only available locally to a function,
like the warrior2 variable.
Like here.
Then you have global scope.
When variables, objects or functions are available to all.
For example, our variable warrior1
or the function screamWarrior is defined
and available in the global scope.
Like this one here and the actual function here.
Then you have blocks scope variables.
Declare with let and const which are available
within the innermost block they are surrounded by.
So if we look at our current code,
the warrior2 and newWarrior are block scope variables
and are accessible in the block they are surrounded by.
Like this one here.
This one here
and also this one here.
This one is available in this block.
This one is available in this block,
so, in the whole file and the same for this one here.
We'll cover later on what is the difference between
the let and the const variable.
We'll also explore all the types in depth over
the course of the following chapters.
We drive the point home and make sure you
are absolutely comfortable with all these types.