Merge pull request #2224 from vsemozhetbyt/patch-11
Mention function declaration in 1.6.5 (global object)
This commit is contained in:
commit
7ddddd299d
1 changed files with 2 additions and 0 deletions
|
@ -25,6 +25,8 @@ var gVar = 5;
|
|||
alert(window.gVar); // 5 (became a property of the global object)
|
||||
```
|
||||
|
||||
The same effect have function declarations (statements with `function` keyword in the main code flow, not function expressions).
|
||||
|
||||
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.
|
||||
|
||||
If we used `let` instead, such thing wouldn't happen:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue