First off, why are closures important to know? The best answer to this so far in my eyes is because it's a common interview question.
Let's start with what we already know and build up from there.
JS Functions have access to:
For example take the following code:
let outside = "fishbowl";
const checkScope = () => {
let inside = "goldfish";
console.log(outside);
console.log(inside);
};
checkScope(); //logs fishbowl and goldfish
JavaScript functions have access to variable in the environment of where it was defined, not where it is called.
? Is it the same as private variables in classes in java? ? You don't want to run a function that ends up affecting all the other private variables of another type