Skip to content

Commit

Permalink
Merge pull request getify#1105 from cssjunkie/patch-1
Browse files Browse the repository at this point in the history
Update ch1.md
  • Loading branch information
getify authored Aug 3, 2017
2 parents 77225d4 + bf15f5d commit e127a50
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 e127a50

Please sign in to comment.