You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This book is the sum of all my study on JavaScript throughout the past few months.
4
+
As as self-taught web developer I read books, watched tutorials and read articles to keep myself updated to the newest version of JavaScript and while doing so I took several notes.
5
+
6
+
I have now compiled all these notes in a concise book, covering almost all the new features that have been added to JavaScript since 2015 until 2018.
7
+
8
+
Writing this book has been a long journey but the end result makes me really proud of having started writing it.
9
+
10
+
As a self-taught developer I know the importance of sharing knowledge and materials and that is why this book can be read online on my [website](https://www.inspiredwebdev.com/courses/the-complete-guide-to-modern-javascript/) or on [GitHub](https://github.com/AlbertoMontalesi/JavaScript-es6-and-beyond-ebook) where more than 170 people already showed their appreciation for it.
11
+
12
+
**Disclaimer**
13
+
14
+
This book is intended for somebody already familiar with the basics of JavaScript, as I am only focusing on the new features introduced by ES6 and I won't be explaining what is a `var`, how to create a function, etc...
15
+
16
+
Additional chapters cover the new features introduced post ES6 (ES2015) all the way to the most recent version, ES2018.
17
+
18
+
19
+
20
+
## Contributions & Donations
21
+
22
+
Any contributions you make are of course greatly appreciated.
23
+
24
+
If you enjoy my content and you want to donate me a cup of coffee, you can do so [here](https://www.paypal.me/albertomontalesi).
25
+
26
+
## License
27
+
28
+
<arel="license"href="http://creativecommons.org/licenses/by-nc-nd/3.0/"><imgalt="Creative Commons License"style="border-width:0"src="https://i.creativecommons.org/l/by-nc-nd/3.0/88x31.png" /></a><br />This work is licensed under a <arel="license"href="http://creativecommons.org/licenses/by-nc-nd/3.0/">Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License</a>.
Copy file name to clipboardExpand all lines: ebook/01_var_let_const.md
+6-4Lines changed: 6 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ console.log(functionScoped);
26
26
// ReferenceError: functionScoped is not defined
27
27
```
28
28
29
-
In the first example the value of the `var` leaked out of the block-scope and could be accessed from outside, whereas in the second example `var` was confined inside a function-scope and we could not access it from outside.
29
+
In the first example the value of the `var` leaked out of the block-scope and could be accessed from outside of it, whereas in the second example `var` was confined inside a function-scope and we could not access it from outside.
30
30
31
31
32
32
@@ -68,7 +68,7 @@ As you can see, when we assigned a new value to our `let` inside our block-scope
68
68
69
69
## `Const`
70
70
71
-
Similarly to `let`, `const` are **block-scoped**, but they differ in the fact that their value **can't change through re-assignment or can't be redeclared**.
71
+
Similarly to `let`, `const` are **block-scoped**, but they differ in the fact that their value **can't change through re-assignment or can't be re-declared**.
72
72
73
73
74
74
```javascript
@@ -93,11 +93,13 @@ const person = {
93
93
}
94
94
95
95
person.age=26;
96
-
96
+
console.log(person.age);
97
+
// 26
97
98
// in this case no error will be raised, we are not re-assigning the variable but just one of its properties.
To tell JavaScript that what's inside the curly braces is an **object literal** that we want to implicitly return, we need to wrap everything inside parenthesis.
@@ -116,7 +114,7 @@ Since we know that **arrow functions** inherit the value of `this` from the pare
116
114
```javascript
117
115
// grab our div with class box
118
116
constbox=document.querySelector(".box");
119
-
// listen for a click event
117
+
// listen for a click event
120
118
box.addEventListener("click", function () {
121
119
// toggle the class opening on the div
122
120
this.classList.toggle("opening");
@@ -127,8 +125,7 @@ box.addEventListener("click", function () {
127
125
});
128
126
```
129
127
130
-
Here, the second `this` will inherit from its parent, and will be therefore set to the `const` box.
131
-
128
+
Here, the second `this` will inherit from its parent, and will be set to the `const` box.
132
129
133
130
134
131
@@ -141,7 +138,7 @@ The next 2 examples all show when to be careful using `this` inside of arrows.
We don't even have to pass the parameters in the same order as when we declared our function, since we are calling them the same way as the arguments JavaScript will know how to match them.
37
37
38
-
Don't worry about destructuring, we will talk about it in a later chapter.
38
+
Don't worry about destructuring, we will talk about it in Chapter 6.
Copy file name to clipboardExpand all lines: ebook/04_template_literals.md
-2Lines changed: 0 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -142,7 +142,6 @@ const markup = `
142
142
143
143
144
144
145
-
146
145
## Tagged template literals
147
146
148
147
By tagging a function to a template literal we can run the template literal through the function, providing it with everything that's inside of the template.
@@ -171,7 +170,6 @@ console.log(sentence);
171
170
We captured the value of the variable age and used a ternary operator to decide what to print.
172
171
`strings` will take all the strings of our `let` sentence whilst the other parameters will hold the variables.
173
172
174
-
175
173
176
174
177
175
To learn more about use cases of *template literals* check out [this article](https://codeburst.io/javascript-es6-tagged-template-literals-a45c26e54761).
Copy file name to clipboardExpand all lines: ebook/07_iterables-and-looping.md
+1-4Lines changed: 1 addition & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -58,15 +58,13 @@ for (const prop of Object.keys(car)){
58
58
59
59
60
60
61
-
62
61
## The `for in` loop
63
62
64
63
Even though it is not a new ES6 loop, let's look at the `for in` loop to understand what differentiate it compared to the `for of.
65
64
66
65
The `for in` loop is a bit different because it will iterate over all the [enumerable properties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties) of an object in no particular order.
67
66
68
-
It is therefore suggested not to add, modify or delete properties of the object during the iteration as there is no guarantee that they will be visited, or if they will be visited before or after being modified.
69
-
67
+
It is therefore suggested not to add, modify or delete properties of the object during the iteration as there is no guarantee that they will be visited, or if they will be visited before or after being modified.
70
68
71
69
```js
72
70
constcar= {
@@ -101,7 +99,6 @@ for (let i in list) {
101
99
for (let i of list) {
102
100
console.log(i); // "4", "5", "6"
103
101
}
104
-
105
102
```
106
103
107
104
`for in` will return a list of keys whereas the `for of` will return a list of values of the numeric properties of the object being iterated.
Copy file name to clipboardExpand all lines: ebook/08_array_improvements.md
+1-3Lines changed: 1 addition & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,7 +69,6 @@ console.log(digits);
69
69
// Array [ 1, 2, 3, 4, 5];
70
70
```
71
71
72
-
73
72
74
73
75
74
## `Array.find()`
@@ -125,5 +124,4 @@ console.log(arrayEvery);
125
124
// false
126
125
```
127
126
128
-
Simply put, the first condition is true, because there are **some** elements greater than 2, but the second is false because **not every element** is greater than 2.
129
-
127
+
Simply put, the first condition is true, because there are **some** elements greater than 2, but the second is false because **not every element** is greater than 2.
0 commit comments