Permalink
Browse files

Fix the description of why 'name' ends up on the global object.

Close #49.

Signed-off-by: DTrejo <david.daniel.trejo@gmail.com>
  • Loading branch information...
mrbkap authored and DTrejo committed Feb 11, 2013
1 parent 818052f commit 5ffbfbe32ba88af6c2bcf4e12a44eed21a02b359
Showing with 2 additions and 13 deletions.
  1. +2 −13 posts/2011-07-26-iteration-demoralization.md
@@ -26,26 +26,15 @@ What you might not have guessed, is what this will output:
console.log(window.name);
</code>
-its:
+it's:
> "2"
-Iteration is assignment, and without the use of the `var` keyword, you're really using the `this` object - which in the context of a raw function declaration is the `window` object.
+Iteration is assignment, and without the use of the `var` keyword, you're really using the global object - which in this context is the `window` object.
So the original function is equivalent to:
-<code>
- function allNames() {
- var names = [ 'dan', 'anthony', 'pavel' ];
- for (this.name in names) {
- console.log(name);
- }
- }
-</code>
-
-Which is also equivalent to:
-
<code>
function allNames() {
var names = [ 'dan', 'anthony', 'pavel' ];

0 comments on commit 5ffbfbe

Please sign in to comment.