Global Scope and Functions

This commit is contained in:
Abhisek Pattnaik
2015-12-26 05:11:41 +05:30
committed by SaintPeter
parent 16c2f69459
commit 82cb368523

View File

@ -1897,8 +1897,8 @@
"id": "56533eb9ac21ba0edf2244be",
"title": "Global Scope and Functions",
"description": [
"In Javascript, <dfn>scope</dfn> refers to the visibility of variables. Variables which are defined outside of a function block have <dfn>Global</dfn> scope. This means the can be seen everywhere in your Javascript code. ",
"Variables which are used without the <code>var</code> keyword are automatically created in the <code>global</code> scope. This can create unintended concequences elsewhere in your code or when running a function again. You should always declare your variables with <code>var</code>.",
"In Javascript, <dfn>scope</dfn> refers to the visibility of variables. Variables which are defined outside of a function block have <dfn>Global</dfn> scope. This means, they can be seen everywhere in your JavaScript code.",
"Variables which are used without the <code>var</code> keyword are automatically created in the <code>global</code> scope. This can create unintended consequences elsewhere in your code or when running a function again. You should always declare your variables with <code>var</code>.",
"<h4>Instructions</h4>",
"Declare a <code>global</code> variable <code>myGlobal</code> outside of any function. Initialize it to have a value of <code>10</code> ",
"Inside function <code>fun1</code>, assign <code>5</code> to <code>oopsGlobal</code> <strong><em>without</em></strong> using the <code>var</code> keyword."
@ -1933,6 +1933,7 @@
"",
"function fun1() {",
" // Assign 5 to oopsGlobal Here",
" ",
"}",
"",
"// Only change code above this line",