Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5750a0a

Browse files
author
Noer Paanakker
committed
finished readings
1 parent 09d0ec6 commit 5750a0a

File tree

3 files changed

+119
-15
lines changed

3 files changed

+119
-15
lines changed

Week1/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ Check the following resources to learn more about XHR.
9696

9797
- [XMLHttpRequest](https://github.com/hackyourfuture/fundamentals/blob/master/fundamentals/XMLHttpRequest.md)
9898
- [AJAX Crash Course](https://www.youtube.com/watch?v=82hnvUYY6QA)
99+
- [Sending JavaScript Http Requests with XMLHttRequest](https://www.youtube.com/watch?v=4K33w-0-p2c)
99100

100101
## 3. Modules & Libraries
101102

Week2/README.md

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ function aFunction() {
2424
}
2525
```
2626

27+
You did so using an old version of JavaScript.
28+
29+
But if you've ever used `arrow` functions (which you'll learn more about in the next section), you did so using a newer version of JavaScript.
30+
31+
That's good and all, but why is this important to differentiate? There are several reasons:
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
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+
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".
37+
38+
Check the following resources out to learn more about this:
39+
2740
- [The History of JavaScript | Why is JavaScript also called ECMAScript?](https://www.youtube.com/watch?v=JpwxjkpZfhY)
2841
- [The Weird History of JavaScript](https://www.youtube.com/watch?v=Sh6lK57Cuk4)
2942

@@ -37,7 +50,7 @@ But what if you want to have callbacks within callbacks... within callbacks? Thi
3750

3851
- [Callback Hell](http://callbackhell.com/)
3952

40-
This is where Promises come in. The concept of a Promise, in execution, doesn't add anything new. It does exactly what callbacks aim to do, which is enabling asynchronous actions: for example, clicking a button to load in an image, while still being able to navigate the webpage.
53+
This is where `Promises` come in. The concept of a Promise, in execution, doesn't add anything new. It does exactly what callbacks aim to do, which is enabling asynchronous actions: for example, clicking a button to load in an image, while still being able to navigate the webpage.
4154

4255
What a Promise does is make writing callbacks more readable for you, the developer. This is its main benefit. In effect, you could call Promises the updated version of callbacks. Callbacks version 2.0.
4356

@@ -49,18 +62,47 @@ Go through the following resources to learn more about Promises:
4962

5063
## 3. Arrow functions
5164

52-
One of a programmer's favorite things to do is to write clean and concise code. Arrow functions are a new way within
65+
One of a programmer's favorite things to do is to write clean and concise code. Arrow functions are a new way to write functions, given to us by the ECMAScript 6 (The software standard JavaScript is based upon) update of JavaScript.
66+
67+
It is written like this:
68+
69+
```js
70+
// Arrow function
71+
() => {};
72+
```
5373

74+
Go through the following resources to learn more about why they're important:
75+
76+
- [JavaScript ES6 Arrow Functions](https://www.youtube.com/watch?v=h33Srr5J9nY)
5477
- [Let's learn ES6 - Arrow functions](https://www.youtube.com/watch?v=oTRujqZYhrU)
78+
- [When (and why) you should use ES6 arrow functions — and when you shouldn’t](https://www.freecodecamp.org/news/when-and-why-you-should-use-es6-arrow-functions-and-when-you-shouldnt-3d851d7f0b26/)
79+
80+
### The `this` keyword
81+
82+
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+
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.
85+
86+
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+
88+
Go through the following resources to learn more about `this`:
89+
90+
- [Understanding "this" in JavaScript](https://www.codementor.io/dariogarciamoya/understanding--this--in-javascript-du1084lyn)
91+
- [JavaScript "this" keyword](https://www.youtube.com/watch?v=gvicrj31JOM)
5592

5693
## 4. Fetch API
5794

5895
Last week you learned about making API calls. You learned how to do this using the XHR object, which we can access through the browser's `window` object.
5996

60-
As we've learned in the previous sections, JavaScript as a language evolves. But so do browsers!
97+
Now as we've learned in the previous sections, JavaScript as a language evolves continually. But so do browsers! New features get added to increase the user experience and make life easier for developers.
98+
99+
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+
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.
61102

62-
It's a modern way to make API calls. It incorporates Promises. 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`.
103+
Learn more about `fetch`:
63104

105+
- [Fetch API Introduction](https://www.youtube.com/watch?v=Oive66jrwBs)
64106
- [Fetch() - Working with Data and APIs in JavaScript](https://www.youtube.com/watch?v=tc8DU14qX6I)
65107

66108
## Finished?

Week3/README.md

Lines changed: 72 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,25 @@ Almost anything that evolves within programming does so to solve a certain probl
6161

6262
The problems that OOP tries to solve is the question we saw before: how can we write code in an organized and reusable fashion?
6363

64-
The answer that OOP gives us can be summarised in the following 4 pillars:
64+
The answer that OOP gives us can be summarised in 4 pillars. To illustrate these pillars let's use a simple example:
6565

66-
1. **Encapsulation**: bundling data and operations (that manipulate that data) together, and data hiding. Putting objects inside of a 'capsule' we can prevent direct manipulation by outside sources. Reducing dependencies between objects, so that change in one place doesn't affect the rest of the application.
66+
```js
67+
const person = {
68+
name: 'Mohammad',
69+
age: 28,
70+
walk() {
71+
return `${this.name} is walking!`;
72+
},
73+
};
74+
```
75+
76+
1. **Encapsulation**: In the example data and operations (that manipulate that data)are grouped together. This is called `encapsulation`. The main benefit is that this keeps our code organised. The second benefit is that putting objects inside of a 'capsule' we can prevent direct manipulation by outside sources, this is called `data hiding`. This reduces dependencies between objects, so that change in one place doesn't affect the rest of the application.
6777

68-
2. **Abstraction**: Complexity of logic hidden away, creating a simpler interface (remote controller to a tv). Only expose the essentials. Abstracting away complexities to create a
78+
2. **Abstraction**: Let's say we had a Complexity of logic hidden away, creating a simpler interface (remote controller to a tv). Only expose the essentials. Abstracting away complexities to create an easier to use element.
6979

7080
3. **Inheritance**: eliminates redundant code by inheriting properties and methods in new instances. This encourages code reusability.
7181

72-
4. **Polymorphism**: an object can have many forms of expression, depending on the context.
82+
4. **Polymorphism**: an object can have many forms of expression, depending on the context. Let's say we inherit
7383

7484
Any class that exists or is made follows these pillars.
7585

@@ -97,31 +107,82 @@ const anObj = {
97107
};
98108
```
99109

100-
This is called an `object literal`, and it's a valid way of creating an object. However, writing it like this abstracts away a lot of what's happening behind the scenes.
110+
This is called an `object literal`, and it's a valid way of creating an object. However, writing it like this "abstracts away" a lot of what's happening behind the scenes.
111+
112+
> To abstract away refers to intentionally hiding the details of how something complex works in order to simplify things conceptually. For example, the remote to your television is a complex device, but all of this is abstracted away so you don't have to deal with it. You just press the ON button and it works.
113+
114+
You can write the same thing by using the Object `constructor function`.
115+
116+
```
117+
118+
```
101119

102-
The same thing
120+
Well what is a constructor function ? Let's start at the beginning: `factory functions`.
103121

104122
### Factory functions
105123

106-
What if we want to create hundreds of object instances?
124+
If we want to create an object we can just use an `object literal` and we're done. But what if we want to create hundreds of object instances of that same object?
125+
126+
For that we use `factory functions`. Don't let the name mislead you though, a factory function is just a regular function. However, the single differentiating factor is that it always returns an object instance: it is a factory that produces object instances, hence the name `factory function`. Here's an example:
127+
128+
```js
129+
// Defining a blueprint for a person:
130+
function createPerson(name, age) {
131+
var obj = {
132+
name: name,
133+
age: age,
134+
walk: function() {
135+
console.log(`${this.name} is walking!`);
136+
},
137+
};
138+
// other code to manipulate our object in some way here
139+
return obj;
140+
}
141+
```
142+
143+
This is the most simple way of defining a `class` and creating object instances from it. Now every time we call this function we're creating a new person object.
144+
145+
```js
146+
const noer = createPerson('Noer', 27);
147+
const wouter = createPerson('Wouter', 33);
148+
const federico = createPerson('Federico', 32);
149+
```
150+
151+
Go through the following to learn more about factory functions:
107152

108153
- [The Factory Pattern](https://www.youtube.com/watch?v=0jTfc4wY6bM)
109154
- [JavaScript Factory Functions](https://www.youtube.com/watch?v=jpegXpQpb3o)
110155

111156
### Constructor functions
112157

158+
`Constructor functions` are ordinary functions that have a special purpose: to create object instances. You can consider them the more advanced version of `factory functions`.
159+
160+
Here's an example:
161+
162+
```js
163+
// // Defining a blueprint for a person:
164+
function Person(name, age) {
165+
this.name = name;
166+
this.age = age;
167+
}
168+
```
169+
170+
The difference with a factory function is the way to instantiate it. Instead of just calling it we have to use the keyword `new`, like so:
171+
172+
```js
173+
const noer = new Person('Noer', 27);
174+
```
175+
113176
- [JavaScript Constructor Functions](https://www.youtube.com/watch?v=23AOrSN-wmI)
114177
- [Constructors and object instances](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Object-oriented_JS#Constructors_and_object_instances)
115178

116179
### Classes
117180

118-
Like mentioned before, a `class` is a blueprint/template that represents a real-world entity. Whenever we want to create a version of this class, we `instantiate` it: in other words, we're creating a object.
119-
120181
As you've learned in the previous section, in JavaScript we can do this using `factory/constructor function`.
121182

122-
Since ES6 we can
183+
Since ES6 we can make use of the `class` keyword, which is a way to create constructor objects as well. It's essentially the same thing as a constructor function, only written in a clearer and more straightforward way.
123184

124-
It's essentially the same thing as a constructor function, only written in a clearer and more straightforward way.
185+
Go through the following to learn more:
125186

126187
- [The Class](https://www.youtube.com/watch?v=sJvPXb_lmPE)
127188
- [An overview of ES6 classes](https://thecodebarbarian.com/an-overview-of-es6-classes)

0 commit comments

Comments
 (0)