GeezerVison is showing github.com — Add introduction about variables · MTco/javascript@483bb56
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 clipboard +4-2Lines changed: 4 additions & 2 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | | -jsbook |
| 1 | +Learn Javascript |
2 | 2 | ====== |
3 | 3 |
|
4 | | -A simple GitBook about JavaScript |
| 4 | +This book will teach you the basics of programming and Javascript. Whether you are an experienced programmer or not, this book is intended for everyone who wishes to learn the JavaScript programming language. |
| 5 | + |
| 6 | +JavaScript (*JS for short*) is the programming language that enables web pages to respond to user interaction beyond the basic level. |
Collapse file
Copy file name to clipboardExpand all lines: SUMMARY.md +2Lines changed: 2 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | # Summary |
2 | 2 |
|
| 3 | +* [Variables](variables/README.md) |
| 4 | + * [Numbers](variables/numbers.md) |
3 | 5 | * [Strings](strings/README.md) |
4 | 6 | * [Creation](strings/create.md) |
5 | 7 | * [Concatenation](strings/concat.md) |
|
Collapse file
Copy file name to clipboardExpand all lines: strings/README.md +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | | -# JavaScript Strings |
| 1 | +# Strings |
2 | 2 |
|
3 | 3 | JavaScript strings share many similarities with string implementations from other high-level languages, such as Python's. They represent text based messages and data. |
4 | 4 |
|
|
Collapse file
Copy file name to clipboard +50Lines changed: 50 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +# Variables |
| 2 | + |
| 3 | +The first step towards understanding programming is looking back at algebra. If you remember from school, algebra starts with writing terms such as the following. |
| 4 | + |
| 5 | +``` |
| 6 | +3 + 5 = 8 |
| 7 | +``` |
| 8 | + |
| 9 | +You start performing calculations when you introduce an unknown, for example x below: |
| 10 | + |
| 11 | +``` |
| 12 | +3 + x = 8 |
| 13 | +``` |
| 14 | + |
| 15 | +Shifting those around you can determine x: |
| 16 | + |
| 17 | +``` |
| 18 | +x = 8 - 3 |
| 19 | +-> x = 5 |
| 20 | +``` |
| 21 | + |
| 22 | +When you introduce more then one you make your term more flexible - you are using variables: |
| 23 | + |
| 24 | +``` |
| 25 | +x + y = 8 |
| 26 | +``` |
| 27 | + |
| 28 | +You can change the values of x and y and the formula can still be true: |
| 29 | + |
| 30 | +``` |
| 31 | +x = 4 |
| 32 | +y = 4 |
| 33 | +``` |
| 34 | + |
| 35 | +or |
| 36 | + |
| 37 | +``` |
| 38 | +x = 3 |
| 39 | +y = 5 |
| 40 | +``` |
| 41 | + |
| 42 | +The same works with programming languages—in programming, variables are containers for values that can vary. Variables can hold all kind of values and also the results of calculations. Variables have a name and a value separated by an equals sign (=). Variable names can be any letter or word, but bear in mind that there are restrictions from language to language of what you can use, as some words are reserved for other functionality. |
| 43 | + |
| 44 | +Let's check out how it works in Javascript, The following defines two variables, calculates the result of adding the two and defines this result as a value of a third variable. |
| 45 | + |
| 46 | +``` |
| 47 | +var x = 5; |
| 48 | +var y = 6; |
| 49 | +var result = x + y; |
| 50 | +``` |