News

A function scope is in a way also a block scope, so let and constwould behave the same way they did in our previous examples. However, function scopes also encapsulate variables declared with var .
Global variables are a common source of logic errors, so keeping a variable in the smallest scope is always good practice. Conclusion Although variables are a fairly simple aspect of JavaScript ...