The next step in mastering JavaScript closures is being able to “get” or “set” a private variable In Part I of this series: JavaScript Closures – The Absolute Basics, I discussed wrapping one function with another, which produces a closure. When that returned function is assigned to a variable, as long as that variable is
Understanding Scope in JavaScript
Although the ‘with’ statement creates a block-level scope effect, and recent implementations of the “let” statement have the same effect, these are fodder for another conversation. I’m not a big fan of the “with” statement, and at the time of this writing, you can’t be 100% sure that the “let” statement is fully supported by
How to Create a Name-Spaced Object to Avoid Using Global Variables in JavaScript
Creating your own custom Object is a good way to keep the global name-space clean and write organized code with predictable results. Sometimes you may need variables that are available to every function in your script. While it is tempting to use global variables to achieve this kind of scope, doing so can cause unpredictable



