From 4a75ea406cd75cc21d4c23e69d7af5f257a49c6c Mon Sep 17 00:00:00 2001 From: Vse Mozhe Buty Date: Wed, 21 Oct 2020 19:59:06 +0300 Subject: [PATCH] Mention function declaration in 1.6.5 (global object) --- 1-js/06-advanced-functions/05-global-object/article.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/1-js/06-advanced-functions/05-global-object/article.md b/1-js/06-advanced-functions/05-global-object/article.md index 679db05c..8afb38ad 100644 --- a/1-js/06-advanced-functions/05-global-object/article.md +++ b/1-js/06-advanced-functions/05-global-object/article.md @@ -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: