Home Posts tagged "global"
formats

Understanding Context in JavaScript – Object Literals

Why is the word “this” so important in JavaScript? In the post: “Understanding Scope in JavaScript,” I covered the basics of how scope works when dealing with functions. Sometimes the words “scope” and “context” are used interchangeably, which only leads to confusion because they are not the same thing. In JavaScript, “context” refers to an

(More)…

formats

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

(More)…

formats

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

(More)…

show
 
close