Skip to content

Commit 7ddddd2

Browse files
authored
Merge pull request javascript-tutorial#2224 from vsemozhetbyt/patch-11
Mention function declaration in 1.6.5 (global object)
2 parents bd0fbbe + 4a75ea4 commit 7ddddd2

File tree

1 file changed

+2
-0
lines changed
  • 1-js/06-advanced-functions/05-global-object

1 file changed

+2
-0
lines changed

1-js/06-advanced-functions/05-global-object/article.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ var gVar = 5;
2525
alert(window.gVar); // 5 (became a property of the global object)
2626
```
2727

28+
The same effect have function declarations (statements with `function` keyword in the main code flow, not function expressions).
29+
2830
Please don't rely on that! This behavior exists for compatibility reasons. Modern scripts use [JavaScript modules](info:modules) where such thing doesn't happen.
2931

3032
If we used `let` instead, such thing wouldn't happen:

0 commit comments

Comments
 (0)