GeezerVison is showing github.com — run prettier and fix typos · codingbycarter/javascript@7608deb
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | node_modules | 2 | 2 | .grunt | 3 | 3 | /_book/ | | 4 | +.vscode |
Collapse file Copy file name to clipboard +2-3Lines changed: 2 additions & 3 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -Learn Javascript | 2 | | -====== | | 1 | +# Learn Javascript | 3 | 2 |
| 4 | 3 | 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 | 4 |
| 6 | 5 |  | 7 | 6 |
| 8 | | -JavaScript (*JS for short*) is the programming language that enables web pages to respond to user interaction beyond the basic level. It was created in 1995, and is today one of the most famous and used programming languages. | | 7 | +JavaScript (_JS for short_) is the programming language that enables web pages to respond to user interaction beyond the basic level. It was created in 1995, and is today one of the most famous and used programming languages. |
Collapse file Copy file name to clipboard +37-38Lines changed: 37 additions & 38 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 | | -* [Basics](basics/README.md) | 4 | | - * [Comments](basics/comments.md) | 5 | | - * [Variables](basics/variables.md) | 6 | | - * [Types](basics/types.md) | 7 | | - * [Equality](basics/equality.md) | 8 | | -* [Numbers](numbers/README.md) | 9 | | - * [Creation](numbers/create.md) | 10 | | - * [Basic Operators](numbers/operators.md) | 11 | | - * [Advanced Operators](numbers/advanced.md) | 12 | | -* [Strings](strings/README.md) | 13 | | - * [Creation](strings/create.md) | 14 | | - * [Concatenation](strings/concat.md) | 15 | | - * [Length](strings/length.md) | 16 | | -* [Conditional Logic](conditional/README.md) | 17 | | - * [If](conditional/if.md) | 18 | | - * [Else](conditional/else.md) | 19 | | - * [Comparators](conditional/comparators.md) | 20 | | - * [Concatenate](conditional/concatenate.md) | 21 | | -* [Arrays](arrays/README.md) | 22 | | - * [Indices](arrays/indices.md) | 23 | | - * [Length](arrays/length.md) | 24 | | -* [Loops](loops/README.md) | 25 | | - * [For](loops/for.md) | 26 | | - * [While](loops/while.md) | 27 | | - * [Do...While](loops/dowhile.md) | 28 | | -* [Functions](functions/README.md) | 29 | | - * [Declare](functions/declare.md) | 30 | | - * [Higher order](functions/higher_order.md) | 31 | | -* [Objects](objects/README.md) | 32 | | - * [Creation](objects/creation.md) | 33 | | - * [Properties](objects/properties.md) | 34 | | - * [Mutable](objects/mutable.md) | 35 | | - * [Reference](objects/reference.md) | 36 | | - * [Prototype](objects/prototype.md) | 37 | | - * [Delete](objects/delete.md) | 38 | | - * [Enumeration](objects/enumeration.md) | 39 | | - * [Global footprint](objects/global_footprint.md) | 40 | | - | | 3 | +- [Basics](basics/README.md) | | 4 | + - [Comments](basics/comments.md) | | 5 | + - [Variables](basics/variables.md) | | 6 | + - [Types](basics/types.md) | | 7 | + - [Equality](basics/equality.md) | | 8 | +- [Numbers](numbers/README.md) | | 9 | + - [Creation](numbers/create.md) | | 10 | + - [Basic Operators](numbers/operators.md) | | 11 | + - [Advanced Operators](numbers/advanced.md) | | 12 | +- [Strings](strings/README.md) | | 13 | + - [Creation](strings/create.md) | | 14 | + - [Concatenation](strings/concat.md) | | 15 | + - [Length](strings/length.md) | | 16 | +- [Conditional Logic](conditional/README.md) | | 17 | + - [If](conditional/if.md) | | 18 | + - [Else](conditional/else.md) | | 19 | + - [Comparators](conditional/comparators.md) | | 20 | + - [Concatenate](conditional/concatenate.md) | | 21 | +- [Arrays](arrays/README.md) | | 22 | + - [Indices](arrays/indices.md) | | 23 | + - [Length](arrays/length.md) | | 24 | +- [Loops](loops/README.md) | | 25 | + - [For](loops/for.md) | | 26 | + - [While](loops/while.md) | | 27 | + - [Do...While](loops/dowhile.md) | | 28 | +- [Functions](functions/README.md) | | 29 | + - [Declare](functions/declare.md) | | 30 | + - [Higher order](functions/higher_order.md) | | 31 | +- [Objects](objects/README.md) | | 32 | + - [Creation](objects/creation.md) | | 33 | + - [Properties](objects/properties.md) | | 34 | + - [Mutable](objects/mutable.md) | | 35 | + - [Reference](objects/reference.md) | | 36 | + - [Prototype](objects/prototype.md) | | 37 | + - [Delete](objects/delete.md) | | 38 | + - [Enumeration](objects/enumeration.md) | | 39 | + - [Global footprint](objects/global_footprint.md) |
Collapse file Copy file name to clipboardExpand all lines: arrays/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 |
|---|
@@ -9,4 +9,4 @@ Here is a simple array: | 9 | 9 | ```javascript | 10 | 10 | // 1, 1, 2, 3, 5, and 8 are the elements in this array | 11 | 11 | var numbers = [1, 1, 2, 3, 5, 8]; | 12 | | -``` | | 12 | +``` |
Collapse file Copy file name to clipboardExpand all lines: arrays/length.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 |
|---|
| 3 | 3 | Arrays have a property called length, and it's pretty much exactly as it sounds, it's the length of the array. | 4 | 4 |
| 5 | 5 | ```javascript | 6 | | -var array = [1 , 2, 3]; | | 6 | +var array = [1, 2, 3]; | 7 | 7 |
| 8 | 8 | // Result: l = 3 | 9 | 9 | var l = array.length; | |
Collapse file Copy file name to clipboardExpand all lines: basics/README.md +2-2Lines changed: 2 additions & 2 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -4,7 +4,7 @@ In this first chapter, we'll learn the basics of programming and the Javascript | 4 | 4 |
| 5 | 5 | Programming means writing code. A book is made up of chapters, paragraphs, sentences, phrases, words and finally punctuation and letters, likewise a program can be broken down into smaller and smaller components. For now, the most important is a statement. A statement is analogous to a sentence in a book. On its own, it has structure and purpose, but without the context of the other statements around it, it isn't that meaningful. | 6 | 6 |
| 7 | | -A statement is more casually (and commonly) known as a *line of code*. That's because statements tend to be written on individual lines. As such, programs are read from top to bottom, left to right. You might be wondering what code (also called source code) is. That happens to be a broad term which can refer to the whole of the program or the smallest part. Therefore, a line of code is simply a line of your program. | | 7 | +A statement is more casually (and commonly) known as a _line of code_. That's because statements tend to be written on individual lines. As such, programs are read from top to bottom, left to right. You might be wondering what code (also called source code) is. That happens to be a broad term which can refer to the whole of the program or the smallest part. Therefore, a line of code is simply a line of your program. | 8 | 8 |
| 9 | 9 | Here is a simple example: | 10 | 10 |
| @@ -16,4 +16,4 @@ var world = "World"; | 16 | 16 | var message = hello + " " + world; | 17 | 17 | ``` | 18 | 18 |
| 19 | | -This code can be executed by another program called an *interpreter* that will read the code, and execute all the statements in the right order. | | 19 | +This code can be executed by another program called an _interpreter_ that will read the code, and execute all the statements in the right order. |
Collapse file Copy file name to clipboardExpand all lines: basics/comments.md +2-27Lines changed: 2 additions & 27 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -4,14 +4,14 @@ Comments are statements that will not be executed by the interpreter, comments a | 4 | 4 |
| 5 | 5 | In Javascript, comments can be written in 2 different ways: | 6 | 6 |
| 7 | | -* Line starting with `//`: | | 7 | +- Line starting with `//`: | 8 | 8 |
| 9 | 9 | ```javascript | 10 | 10 | // This is a comment, it will be ignored by the interpreter | 11 | 11 | var a = "this is a variable defined in a statement"; | 12 | 12 | ``` | 13 | 13 |
| 14 | | -* Section of code starting with `/*`and ending with `*/`, this method is used for multi-line comments: | | 14 | +- Section of code starting with `/*`and ending with `*/`, this method is used for multi-line comments: | 15 | 15 |
| 16 | 16 | ```javascript | 17 | 17 | /* | @@ -20,28 +20,3 @@ it will be ignored by the interpreter | 20 | 20 | */ | 21 | 21 | var a = "this is a variable defined in a statement"; | 22 | 22 | ``` | 23 | | - | 24 | | - | 25 | | ---- | 26 | | - | 27 | | -Mark the editor's contents as a comment | 28 | | - | 29 | | -```js | 30 | | - | 31 | | -Mark me as a comment | 32 | | -or I'll throw an error | 33 | | -
| 34 | | -``` | 35 | | -
| 36 | | -```js | 37 | | -/* | 38 | | -Mark me as a comment | 39 | | -or I'll throw an error | 40 | | -*/ | 41 | | -``` | 42 | | - | 43 | | -```js | 44 | | -assert(true); | 45 | | -``` | 46 | | - | 47 | | ---- |
Collapse file Copy file name to clipboardExpand all lines: basics/equality.md +4-3Lines changed: 4 additions & 3 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 |
| 3 | 3 | Programmers frequently need to determine the equality of variables in relation to other variables. This is done using an equality operator. | 4 | 4 |
| 5 | | -The most basic equality operator is the `==` operator. This operator does everything it can to determine if two variables are equal, even if they are not of the same type. | | 5 | +The most basic equality operator is the `==` operator. This operator does everything it can to determine if two variables are equal, even if they are not of the same type. | 6 | 6 |
| 7 | 7 | For example, assume: | | 8 | + | 8 | 9 | ```javascript | 9 | 10 | var foo = 42; | 10 | 11 | var bar = 42; | 11 | 12 | var baz = "42"; | 12 | 13 | var qux = "life"; | 13 | 14 | ``` | 14 | 15 |
| 15 | | -`foo == bar` will evaluate to `true` and `baz == qux` will evaluate to `false`, as one would expect. However, `foo == baz` will *also* evaluate to `true` despite `foo` and `baz` being different types. Behind the scenes the `==` equality operator attempts to force its operands to the same type before determining their equality. This is in contrast to the `===` equality operator. | | 16 | +`foo == bar` will evaluate to `true` and `baz == qux` will evaluate to `false`, as one would expect. However, `foo == baz` will _also_ evaluate to `true` despite `foo` and `baz` being different types. Behind the scenes the `==` equality operator attempts to force its operands to the same type before determining their equality. This is in contrast to the `===` equality operator. | 16 | 17 |
| 17 | | -The `===` equality operator determines that two variables are equal if they are of the same type *and* have the same value. With the same assumptions as before, this means that `foo === bar` will still evaluate to `true`, but `foo === baz` will now evaluate to `false`. `baz === qux` will still evaluate to `false`. | | 18 | +The `===` equality operator determines that two variables are equal if they are of the same type _and_ have the same value. With the same assumptions as before, this means that `foo === bar` will still evaluate to `true`, but `foo === baz` will now evaluate to `false`. `baz === qux` will still evaluate to `false`. |
Collapse file Copy file name to clipboardExpand all lines: basics/types.md +11-10Lines changed: 11 additions & 10 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -4,23 +4,24 @@ Computers are sophisticated and can make use of more complex variables than just | 4 | 4 |
| 5 | 5 | The most common types are: | 6 | 6 |
| 7 | | -* **Numbers** | 8 | | - * **Float**: a number, like 1.21323, 4, -33.5, 100004 or 0.123 | 9 | | - * **Integer**: a number like 1, 12, -33, 140 but not 1.233 | | 7 | +- **Numbers** | 10 | 8 |
| 11 | | -* **String**: a line of text like "boat", "elephant" or "damn, you are tall!" | | 9 | + - **Float**: a number, like 1.21323, 4, -33.5, 100004 or 0.123 | | 10 | + - **Integer**: a number like 1, 12, -33, 140 but not 1.233 | 12 | 11 |
| 13 | | -* **Boolean**: either true or false, but nothing else | | 12 | +- **String**: a line of text like "boat", "elephant" or "damn, you are tall!" | 14 | 13 |
| 15 | | -* **Arrays**: a collection of values like: 1,2,3,4,'I am bored now' | | 14 | +- **Boolean**: either true or false, but nothing else | 16 | 15 |
| 17 | | -* **Objects**: a representation of a more complex object | | 16 | +- **Arrays**: a collection of values like: 1,2,3,4,'I am bored now' | 18 | 17 |
| 19 | | -* **null**: a variable that contains null contains no valid Number, String, Boolean, Array, or Object | | 18 | +- **Objects**: a representation of a more complex object | 20 | 19 |
| 21 | | -* **undefined**: the undefined value is obtained when you use an object property that does not exist, or a variable that has been declared, but has no value assigned to it. | | 20 | +- **null**: a variable that contains null contains no valid Number, String, Boolean, Array, or Object | 22 | 21 |
| 23 | | -JavaScript is a *“loosely typed”* language, which means that you don't have to explicitly declare what type of data the variables are. You just need to use the ```var``` keyword to indicate that you are declaring a variable, and the interpreter will work out what data type you are using from the context, and use of quotes. | | 22 | +- **undefined**: the undefined value is obtained when you use an object property that does not exist, or a variable that has been declared, but has no value assigned to it. | | 23 | + | | 24 | +JavaScript is a _“loosely typed”_ language, which means that you don't have to explicitly declare what type of data the variables are. You just need to use the `var` keyword to indicate that you are declaring a variable, and the interpreter will work out what data type you are using from the context, and use of quotes. | 24 | 25 |
| 25 | 26 | {% exercise %} | 26 | 27 | Create a variable named `a` using the keyword `var`. | |
Collapse file Copy file name to clipboardExpand all lines: conditional/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 |
|---|
@@ -6,4 +6,4 @@ First of all conditions can be used to ensure that your program works, regardles | 6 | 6 |
| 7 | 7 | The other thing conditions can do for you is allow for branching. You might have encountered branching diagrams before, for example when filling out a form. Basically, this refers to executing different “branches” (parts) of code, depending on if the condition is met or not. | 8 | 8 |
| 9 | | -In this chapter, we'll learn the base of conditional logic in Javascript. | | 9 | +In this chapter, we'll learn the base of conditional logic in Javascript. |
|