Skip to content

Commit

Permalink
Update ch1.md
Browse files Browse the repository at this point in the history
The term "global variable" was used when "global object" is called for, on line 235.
  • Loading branch information
cssjunkie authored Aug 3, 2017
1 parent 77225d4 commit bf15f5d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion types & grammar/ch1.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ if (!window.atob) {

Unlike referencing undeclared variables, there is no `ReferenceError` thrown if you try to access an object property (even on the global `window` object) that doesn't exist.

On the other hand, manually referencing the global variable with a `window` reference is something some developers prefer to avoid, especially if your code needs to run in multiple JS environments (not just browsers, but server-side node.js, for instance), where the global variable may not always be called `window`.
On the other hand, manually referencing the global variable with a `window` reference is something some developers prefer to avoid, especially if your code needs to run in multiple JS environments (not just browsers, but server-side node.js, for instance), where the global object may not always be called `window`.

Technically, this safety guard on `typeof` is useful even if you're not using global variables, though these circumstances are less common, and some developers may find this design approach less desirable. Imagine a utility function that you want others to copy-and-paste into their programs or modules, in which you want to check to see if the including program has defined a certain variable (so that you can use it) or not:

Expand Down

0 comments on commit bf15f5d

Please sign in to comment.