From 9621e372d0776524b2ba6d697d45749f5725e260 Mon Sep 17 00:00:00 2001 From: Eric Jae-Min Joo Date: Fri, 30 Nov 2018 07:21:49 -0500 Subject: [PATCH] Add proper indentation to example code (#23794) --- .../javascript/global-variables/index.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/guide/english/javascript/global-variables/index.md b/guide/english/javascript/global-variables/index.md index 1dd6140106..f6cb827244 100644 --- a/guide/english/javascript/global-variables/index.md +++ b/guide/english/javascript/global-variables/index.md @@ -5,23 +5,22 @@ title: Global Variables Global variables are declared outside of a function for accessibility throughout the program, while local variables are stored within a function using `var` for use only within that function's [scope](https://developer.mozilla.org/en-US/docs/Glossary/Scope). If you declare a variable without using `var`, even if it's inside a function, it will still be seen as global: ```javascript -var x = 5; //global +var x = 5; //global variable function someThing(y) { -var z = x + y; -console.log(z); + var z = x + y; + console.log(z); } function someThing(y) { -x = 5; //still global! -var z = x + y; -console.log(z); + x = 5; //still a global variable! + var z = x + y; + console.log(z); } - function someThing(y) { -var x = 5; //local -var z = x + y; -console.log(z); + var x = 5; //local variable + var z = x + y; + console.log(z); } ``` A global variable is also an object of the current scope, such as the browser window: