GeezerVison is showing github.com — Merge pull request #11 from Exarchiasghost/master · gurucharanD/JavaScript-Lessons@8447792
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: Basic_Concepts/Scope/README.md +26-12Lines changed: 26 additions & 12 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
|
2 | 2 |
|
3 | 3 | # Scope |
4 | 4 |
|
5 | | -This MD file serves as example/template. |
| 5 | +According [Wikipedia](https://en.wikipedia.org/wiki/Variable_%28computer_science%29#Scope_and_extent): |
| 6 | +*"Scope is an important part of the name resolution of a variable. Most languages define a specific scope for each variable (as well as any other named entity), which may differ within a given program. The scope of a variable is the portion of the program code for which the variable's name has meaning and for which the variable is said to be "visible"."* |
6 | 7 |
|
7 | | -It will be filled up soon. |
8 | 8 |
|
9 | | -(for Bucky to fill up) |
| 9 | +# Course Documentation |
10 | 10 |
|
11 | 11 |
|
12 | | -# Course Documentation |
| 12 | +## Scope and Variables |
| 13 | + |
| 14 | +Variables are the names of the places that some value is stored and the most typical syntax to create them is: |
| 15 | + |
| 16 | + var variablesname = valueofvariable; |
| 17 | + |
| 18 | + |
| 19 | +and after the creation we are typically changing the value with this syntax: |
13 | 20 |
|
14 | | -(this for me to fill up with every element |
| 21 | + variablesname = newvalueforthevariable; |
15 | 22 |
|
16 | | -that you use in lessons. syntax |
| 23 | + |
| 24 | +And if it is not clear the easiest thing in the world is to access the variable just by writing the variable there where we will use its value: |
| 25 | + |
| 26 | + console.log(variablesname) |
17 | 27 |
|
18 | | -explaination and links for more) |
| 28 | + |
| 29 | +Scope on the other hand is about variable's inheritance, (with other words how accessible can a variable be). Typically it has two levels: |
19 | 30 |
|
20 | | -## Element to explain |
| 31 | + - **Global** External variable when every function can access it. |
| 32 | + - **Local** Internal variable when only the function that |
21 | 33 |
|
22 | | -(for example console.log) |
| 34 | + |
| 35 | +In our example we used things like this. to manipulate our variables in a special way. This is called a JavaScript closure. It makes it possible for a function to have "private" variables or use private variables in a special way. (see Objected Oriented Programming or Classes.) |
| 36 | + |
| 37 | +For more information please check the [W3schools Javascript closures' documentation page](http://www.w3schools.com/js/js_function_closures.asp). |
| 38 | + |
23 | 39 |
|
24 | | -***Links*** |
25 | | - - Wikipedia |
26 | | - - Anotherlink,com |
| 40 | +> Written with [StackEdit](https://stackedit.io/). |