In JavaScript, each function has a scope, which is essentially a collection of variables and rules defining how their unique name accesses those variables. You can access a function’s scoped variables only through the code inside that function. While variables contained in a particular scope must have unique names, a scope can exist within another scope. In this case, the code of the innermost scope can access the variables contained in either of the scopes.