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
Copy file name to clipboardExpand all lines: Week2/README.md
+25-6Lines changed: 25 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ These are the topics for week 2:
14
14
15
15
## 1. JavaScript Versions
16
16
17
-
You are undoubtably different than when you were a baby. Back then you couldn't really do much: crying, laughing and taking dumps. That's pretty much it. But as the years pass you increasingly could do more and more: walking, socializing or playing an instrument.
17
+
You are undoubtedly different than when you were a baby. Back then you couldn't do much except crying. That's pretty much it. But as the years pass you increasingly could do more and more: walking, socializing or playing an instrument.
18
18
19
19
Likewise, so has JavaScript evolved. Throughout the course you have, unknowingly, used syntax from different JavaScript versions. For example, if you've ever declared a function like this:
20
20
@@ -30,7 +30,7 @@ But if you've ever used `arrow` functions (which you'll learn more about in the
30
30
31
31
That's good and all, but why is this important to differentiate? There are several reasons:
32
32
33
-
- Each feature (and its updates) of a language is made to solve a specific problem. It's important to know the context and purpose of each in order to know how to use it
33
+
- Each feature (and its updates) of a language is made to solve a specific problem. It's important to know the context and purpose of each to know how to use it
34
34
- Software is always evolving. This means that there are different versions that different users might be using. This means not every feature will work for every application.
35
35
36
36
That's why it's important to know a little about the history of JavaScript: it will make you think of JavaScript (and hopefully software in general) as a continually evolving thing, as opposed to "just a bunch of concepts and techniques you need to memorize".
@@ -67,11 +67,30 @@ One of a programmer's favorite things to do is to write clean and concise code.
67
67
It is written like this:
68
68
69
69
```js
70
+
constnumbers= [2,3,7,8];
71
+
72
+
//classical way
73
+
functionisBiggerThanFive(number) {
74
+
if ( number >5 )
75
+
returntrue;
76
+
else
77
+
returnfalse;
78
+
}
79
+
console.log(numbers.filter(isBiggerThanFive))
80
+
70
81
// Arrow function
71
-
() => {};
82
+
console.log(numbers.filter((number) => {
83
+
if ( number >5 )
84
+
returntrue;
85
+
else
86
+
returnfalse;
87
+
}))
88
+
89
+
// or even shorter, if one arguments no need for (), if return statement no need for {}
90
+
console.log(numbers.filter(number=> number >5));
72
91
```
73
92
74
-
Go through the following resources to learn more about why they're important:
93
+
Go through the following resources to learn more about why arrow functions are important:
@@ -81,7 +100,7 @@ Go through the following resources to learn more about why they're important:
81
100
82
101
In JavaScript, like in any other programming language you'll find, there are certain special keywords that always create a specific effect. The `this` keyword is one of those.
83
102
84
-
In everyday communication we use words like "this" or "that" whenever we want to refer to things in the world or something someone said. It's similarly used in JavaScript.
103
+
In everyday communication, we use words like "this" or "that" whenever we want to refer to things in the world or something someone said. It's similarly used in JavaScript.
85
104
86
105
Simply put: `this` refers to any object it's defined in. The global object, `window` is the default value of `this`. However, anything a new object is created will have its own `this` value.
87
106
@@ -98,7 +117,7 @@ Now as we've learned in the previous sections, JavaScript as a language evolves
98
117
99
118
One of those features added to browsers is an upgraded version of the XHR object. It's called `fetch` and it's the modern way to make API calls. It incorporates Promises, making it easier to handle your server responses.
100
119
101
-
A `fetch` function is now provided in the global `window` scope in the browser. You can check it out by opening your developers tools and searching for `fetch`. Keep in mind that this only counts for certain browser version. To figure out which browsers can use fetch, check [this](https://caniuse.com/#feat=fetch) out.
120
+
A `fetch` function is now provided in the global `window` scope in the browser. You can check it out by opening your developers tools and searching for `fetch`. Keep in mind that `fetch` only works on newer browser version. To figure out which browsers can use fetch, check [this](https://caniuse.com/#feat=fetch) out.
0 commit comments