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

Skip to content

Commit ef20ec7

Browse files
committed
Update text content for class 23
1 parent 6bbecf4 commit ef20ec7

File tree

12 files changed

+279
-46
lines changed

12 files changed

+279
-46
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"page": true,
1010
"browser": true,
1111
"context": true,
12-
"jestPuppeteer": true
12+
"jestPuppeteer": true,
13+
"axios": "readonly"
1314
},
1415
"rules": {
1516
"prettier/prettier": ["error"],

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ or links, please share them by [opening a pull request](https://github.com/HackY
33

44
# HackYourFuture JavaScript 3
55

6-
Here you can find course content and homework for the JavaScript3 modules
6+
Here you can find course content and homework for the JavaScript3 modules.
77

88
|Week|Topic|Read|Homework|
99
|----|-----|----|--------|
10-
|1.|• Structure for a basic SPA (Single Page Application) <br>• [XMLHttpRequests](../../../fundamentals/blob/master/fundamentals/XMLHttpRequest.md) <br>• API calls|[Reading Week 1](/Week1/README.md)|[Homework Week 1](/Week1/MAKEME.md)|
11-
|2.|[Event Loop (order of execution)](../../../fundamentals/blob/master/fundamentals/event_loop.md)<br>• [Promises](../../../fundamentals/blob/master/fundamentals/promises.md)|[Reading Week 2](/Week2/README.md)|[Homework Week 2](/Week2/MAKEME.md)|
12-
|3.|[try...catch](../../../fundamentals/blob/master/fundamentals/try_catch.md)<br>• [async/await](../../../fundamentals/blob/master/fundamentals/async_await.md)<br>• [The `this` keyword](../../../fundamentals/blob/master/fundamentals/this.md)<br>• call, apply, bind<br>• [Object Oriented Programming and ES6 Classes](../../../fundamentals/blob/master/fundamentals/oop_classes.md)|[Reading Week 3](/Week3/README.md)|[Homework Week 3](/Week3/MAKEME.md)|
10+
|1.|• Structure for a basic SPA (Single Page Application) <br>• AJAX & XMLHttpRequests<br>• API calls|[Reading Week 1](/Week1/README.md)|[Homework Week 1](/Week1/MAKEME.md)|
11+
|2.|• Event Loop (order of execution)<br>• Promises|[Reading Week 2](/Week2/README.md)|[Homework Week 2](/Week2/MAKEME.md)|
12+
|3.|fetch, axios<br>• async/await<br>try...catch<br>• The `this` keyword<br>• call, apply, bind<br>• Object Oriented Programming and ES6 Classes|[Reading Week 3](/Week3/README.md)|[Homework Week 3](/Week3/MAKEME.md)|
1313

1414
__Kind note:__
1515

@@ -18,6 +18,6 @@ We expect you to __always__ come prepared to the class on Sunday.
1818
### Overall
1919
A good understanding of all the above mentioned topics. Want to check your Knowledge? Go through the [JavaScript Fundamentals README](../../../fundamentals/blob/master/README.md) and research/ ask for help (Slack!) with the concepts that are not entirely clear.
2020

21-
*The HackYourFuture curriculum is subject to CC BY copyright. This means you can freely use our materials, but just make sure to give us credit for it :)*
21+
*The HackYourFuture curriculum is subject to CC BY copyright. This means you can freely use our materials, but just make sure to give us credit for it* :).
2222

2323
<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.

Week1/MAKEME.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ _**Do not change or delete any files outside of the `homework` folder!**_
155155

156156
**`style.css`**
157157

158-
- Add your own styling.
158+
- Add your own CSS styling. Use `style.css` for all your styling your HTML. Avoid using JavaScript for styling unless there is a genuine need.
159+
160+
**You are not allowed to use a CSS library such as Bootstrap.**
159161

160162
**Hints:**
161163

Week1/README.md

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,73 @@
33
```
44
In week one we will discuss the following topics:
55
• Structure for a basic SPA (Single Page Application)
6-
• XMLHttpRequests
6+
AJAX & XMLHttpRequests
77
• API calls
88
```
99

1010
Here are resources that we like you to read as a preparation for the first lecture:
1111

12-
### Fundamentals
12+
## 1. DOM manipulation
1313

14-
- [XMLHttpRequest](../../../../fundamentals/blob/master/fundamentals/XMLHttpRequest.md)
14+
To refresh your DOM manipulation skills, watch this YouTube video series from Traversy Media:
1515

16-
### APIs
16+
- [JavaScript DOM Crash Course](https://youtu.be/0ik6X4DJKCc).
1717

18-
- Read about APIS: https://www.programmableweb.com/api-university/what-are-apis-and-how-do-they-work
19-
- Traversy Media (YouTube, 18 mins): [What Is A RESTful API? Explanation of REST & HTTP](https://youtu.be/Q-BpqyOT3a8).
18+
You will be using these particular DOM manipulation methods and properties in the JS3 homework for the next three weeks:
2019

21-
### AJAX & XMLHttpRequests
20+
#### Course Video Part 1 (39 mins):
21+
22+
- `document.getElementById()`
23+
- `element.textContent`
24+
25+
#### Course Video Part 2 (21 mins):
26+
27+
- `document.createElement()`
28+
- `element.setAttribute()`
29+
- `element.appendChild()`
30+
31+
#### Course Video Part 3 (34 mins):
32+
33+
- `change` event (`<select>` element)
34+
- `element.addEventListener()`
35+
36+
Note that throughout the video lectures the presenter uses `var` to declare variables. We prefer that you use `const` and `let` instead in your homework.
37+
38+
## 2. APIs
39+
40+
In the homework we will be using the GitHub API. Learn about remote Web APIs in general from this YouTube video (18 min) from Traversy Media:
41+
42+
- [What Is A RESTful API? Explanation of REST & HTTP](https://youtu.be/Q-BpqyOT3a8).
43+
44+
For more research, check out the following resources:
45+
46+
- [What are APIs - series](https://www.youtube.com/watch?v=cpRcK4GS068&list=PLcgRuP1JhcBP8Kh0MC53GH_pxqfOhTVLa)
47+
48+
## 3. AJAX & XMLHttpRequests
49+
50+
Please watch the first 45 mins of the Ajax Crash Course (up until the PHP examples) by Traversy Media:
51+
52+
- [Ajax Crash Course](https://youtu.be/82hnvUYY6QA)
53+
54+
The example code in this course is using on ES5 syntax. In the **traversy_ajax_crash** folder in this repo you will find updated example code (**ajax1**...**ajax3**) that use the ES6 syntax and styling that we prefer in HYF. Specifically, the following changes have been made:
55+
56+
1. The JavaScript code has been placed in a separate file, loaded with a `<script>` tag from the HTML file.
57+
2. Instead of **var** to declare a variable, **const** and **let** are used.
58+
3. The non-strict equality operator `==` has been replaced with the strict version `===`.
59+
4. Functions are defined before they are used.
60+
5. Anonymous functions use the arrow syntax instead of the **function** keyword. Consequently, the `this` value inside the **XMLHttpRequest** event handlers have been replaced with the `xhr` variable name.
61+
6. The `for...in` loops for iterating through an array have been replace with `for...of`.
62+
63+
Read more about using **XMLHttpRequest**:
2264

23-
- Watch the [Ajax Crash Course](./ajaxcrash) (45 mins) from Traversy Media.
2465
- [Making HTTP Requests in JavaScript](https://www.kirupa.com/html5/making_http_requests_js.htm)
2566

2667
### Clean Code
2768

28-
- [How to write clean code? Lessons learnt from “The Clean Code” — Robert C. Martin](https://medium.com/mindorks/how-to-write-clean-code-lessons-learnt-from-the-clean-code-robert-c-martin-9ffc7aef870c).
29-
30-
> Note that this article includes some code examples written in Java, but the same principles can equally be applied to JavaScript.
69+
- [How to write clean code? Lessons learnt from “The Clean Code” — Robert C. Martin](https://medium.com/mindorks/how-to-write-clean-code-lessons-learnt-from-the-clean-code-robert-c-martin-9ffc7aef870c). Note that this article includes some code examples written in Java, but the same principles can equally be applied to JavaScript.
3170

3271
- [Clean Code concepts adapted for JavaScript](https://github.com/ryanmcdermott/clean-code-javascript)
3372

3473
### Handing in homework using GitHub pull requests
3574

36-
- [Handing in homework](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/homework_pr.md)
75+
- HYF Fundamental - [Handing in homework](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/homework_pr.md)

Week1/traversy_ajax_crash/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ The example code in this course is using on ES5 syntax. In the **ajaxcrash** fol
1111
5. Anonymous functions use the arrow syntax instead of the **function** keyword. Consequently, the `this` value inside the **XMLHttpRequest** event handlers have been replaced with the `xhr` variable name.
1212
6. The `for...in` loops for iterating through an array have been replace with `for...of`.
1313

14-
Watch this YouTube video up until the PHP examples (45 mins):
14+
Watch this YouTube video up until the PHP examples (the first 45 mins):
1515

16-
> Traversy Media - [Ajax Crash Course](https://youtu.be/82hnvUYY6QA)
16+
- Traversy Media - [Ajax Crash Course](https://youtu.be/82hnvUYY6QA)

Week2/README.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,24 @@ In week two we will discuss the following topics:
99

1010
Here are resources that we like you to read as a preparation for the second lecture:
1111

12-
### Async VS Sync
13-
Traversy Media - [Async JS Crash Course - Callbacks, Promises, Async Await](./traversy_async_crash)
12+
## Async vs Sync
1413

15-
- [Stacks/Queues](https://www.youtube.com/watch?v=wjI1WNcIntg) (5 mins)
16-
- Read about Asynchronous vs. Synchronous programming: http://www.hongkiat.com/blog/synchronous-asynchronous-javascript/
17-
- [Why closures are helpful with async code](http://stackoverflow.com/questions/13343340/calling-an-asynchronous-function-within-a-for-loop-in-javascript)
14+
Watch this YouTube video (24 mins) from Traversy Media, introducing **promises** and **async/await**. In this week's lecture and homework we will focus on promises as an elegant replacement for callbacks. Next week we will cover async/await, which provides an alternative syntax for 'consuming' promises.
1815

19-
### Fundamentals
16+
- [Async JS Crash Course - Callbacks, Promises, Async Await](https://youtu.be/PoRJizFvM7s)
2017

21-
- [Event Loop](../../../../fundamentals/blob/master/fundamentals/event_loop.md)
22-
- [Promises](../../../../fundamentals/blob/master/fundamentals/promises.md)
18+
Read about Asynchronous vs Synchronous:
19+
20+
- [Understanding Synchronous and Asynchronous JavaScript](http://www.hongkiat.com/blog/synchronous-asynchronous-javascript/)
21+
22+
## Event Loop
23+
24+
- HYF Fundamental - [The Event Loop](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/event_loop.md)
25+
26+
## ES6 Promises
27+
28+
- [A Simple Guide to ES6 Promises](https://codeburst.io/a-simple-guide-to-es6-promises-d71bacd2e13a)
29+
- HYF Fundamental - [Promises](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/promises.md)
2330

2431

2532
_Please go through the material and come to class prepared!_

Week3/MAKEME.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,27 @@ Object Oriented Programming is a vast topic and in this homework we can only scr
8181
8282
| File | Description |
8383
| -----| ------------ |
84-
| index.html | The application's HTML file. |
85-
| style.css | CSS styling. |
84+
| index.html* | The application's HTML file. |
85+
| style.css* | CSS styling. |
8686
| hyf.png | The HYF logo. |
8787
| App.js | The **App** class is the main container class for the app. |
8888
| Observable.js | The **Observable** class is a base class implementing functionality of the Observer pattern. |
89-
| Model.js | The **Model** class is concerned with all data handling (e.g. fetching). Extends the Observable class. |
89+
| Model.js* | The **Model** class is concerned with all data handling (e.g. fetching). Extends the Observable class. |
9090
| HeaderView.js | The **HeaderView** class renders the header with the select element. |
91-
| RepoView.js | The **RepoView** class renders the details for the selected repository. |
92-
| ContributorsView.js | The **ContributorsView** class renders the contributors for the selected repository. |
91+
| RepoView.js* | The **RepoView** class renders the details for the selected repository. |
92+
| ContributorsView.js* | The **ContributorsView** class renders the contributors for the selected repository. |
9393
| ErrorView.js | The **ErrorView** class renders an error, if present. |
9494
| Util.js | The **Utility** class provides (static) utility functions. |
9595

96-
>For this part of the homework you should modify the **RepoView.js** and **ContributorsView.js** files, by adding and adapting code from your non-OOP version of the homework to these files. You should also copy the styling from your non-OOP version. Other files should not be modified.
96+
>For this part of the homework you should only modify the files indicated with an asterisk in the table above.
97+
98+
1. Copy CSS styling from your non-OOP version of the homework into **style.css**.
99+
2. Add a `<script>` tag in the `<head>` section of **index.html** to load the **axios** library package.
100+
3. Modify **Model.js** to use **axios** instead of **fetch** for fetching data.
101+
4. Add and adapt code from your non-OOP version of the homework to **RepoView.js** and **ContributorsView.js**.
102+
5. Do not change any other files.
103+
104+
**index.html**, **RepoView.js** and **ContributorsView.js** files, by adding and adapting code from your non-OOP version of the homework to these files. You should also copy the styling from your non-OOP version. Other files should not be modified.
97105

98106
Figure 1 below illustrates the interrelationship between the various classes in the application using a [UML Class Diagram](https://en.wikipedia.org/wiki/Class_diagram). This particular one was created with with **LucidChart** ([YouTube tutorial](https://youtu.be/UI6lqHOVHic), 10 mins).
99107

@@ -112,6 +120,10 @@ _Read:_
112120
- HYF fundamental: [ES6 Classes](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/oop_classes.md#es6-classes)
113121
- More on ES6 classes: [ES6 Classes in Depth](https://ponyfoo.com/articles/es6-classes-in-depth)
114122

123+
#### 3.2.4 axios
124+
125+
Replace `fetch`
126+
115127
#### 3.2.4 ARIA-compliance (BONUS)
116128

117129
Please review the material from the HTML/CSS module: [Get familiar with Accessible Rich Internet Applications (ARIA)](https://github.com/HackYourFuture/HTML-CSS/tree/master/Week1#get-familiar-with-accessible-rich-internet-applications-aria).

Week3/README.md

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,62 @@ In week three we will discuss the following topics:
99

1010
Here are resources that we like you to read as a preparation for the third lecture:
1111

12-
### async/await
12+
## 1. fetch
1313

14+
Watch this YouTube video to learn about **fetch**. You can find the corresponding code examples in the **traversy_fetch_api** folder. Note that we have moved the inline JavaScript code from `index.html` into a separate `app.js` file. To run this code, open the HTML file by right-clicking its name in the VSCode Explorer and select **Open with Live Server** from the context menu.
1415

15-
### OOP
16+
- Traversy Media (YouTube, 31 mins): [Fetch API Introduction](https://youtu.be/Oive66jrwBs)
1617

17-
Watch Traversy Media's [JavaScript OOP Crash Course (ES5 & ES6)](./traversy_oop_crash) on YouTube (40 mins).
18+
## 2. axios
1819

19-
See also: Fundamental - [Object-Oriented Programming & Classes](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/oop_classes.md)
20+
The **fetch** API is available in all modern browsers, except in Internet Explorer. However, it is not available in Node.js for backend applications. An alternative to **fetch** is the **axios** library. This library supports ES6 promises and uses **XMLHttpRequest** internally when used in a browser, and Node.js primitive functions when used in the backend. These details are hidden to the developer using **axios** who just sees a universal interface (methods and properties), irrespective of whether working in the frontend (browser) or backend (Node.js).
2021

21-
### `this`, `call` `apply`, `bind`
22+
Review the first example from the **axios** repository on GitHub:
2223

23-
- [What is 'this'?](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/this.md)
24-
- [Function.prototype.call()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
25-
- [Function.prototype.apply()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply)
26-
- [Function.prototype.bind()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
24+
- https://github.com/axios/axios
2725

26+
Read:
2827

29-
## Recommended Readings
28+
- [Fetch vs. Axios.js for making HTTP requests](https://medium.com/@thejasonfile/fetch-vs-axios-js-for-making-http-requests-2b261cdd3af5)
3029

31-
[Eloquent JavaScript: Chapter 6 - The Secret Life of Objects](http://eloquentjavascript.net/06_object.html). Read up to the section of **Maps**.
30+
## 3. async/await
31+
32+
Revisit the video from last week for async/await (skip to 20:00 on the timeline):
33+
34+
- Traversy Media (YouTube, 24 mins) - [Async JS Crash Course - Callbacks, Promises, Async Await](https://youtu.be/PoRJizFvM7s?t=1200)
35+
36+
**async/await** is an alternative syntax for 'consuming' ES6 promises, in place of calling **.then()** method. It was introduced in ES7. To handle errors, instead of calling **.catch()**, you need to wrap the code that uses **await** in a **try/catch** block
37+
38+
Read:
39+
40+
- HYF Fundamental - [async & await](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/async_await.md)
41+
- HYF Fundamental - [try...catch](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/try_catch.md)
42+
43+
## 4. OOP
44+
45+
Watch Traversy Media's JavaScript OOP Crash Course (YouTube, 40 mins). A link to the video and more details can be found here:
46+
47+
- [JavaScript OOP Crash Course (ES5 & ES6)](./traversy_oop_crash).
48+
49+
For another perspective, (optionally) watch the following YouTube playlist (11 videos, 66 mins). You may want to quickly step through the first three videos, as they repeat material that should already quite familiar to you.
3250

51+
- The Net Ninja - [Object Oriented JavaScript](https://www.youtube.com/playlist?list=PL4cUxeGkcC9i5yvDkJgt60vNVWffpblB7)
52+
53+
Read:
54+
55+
- HYF Fundamental - [Object-Oriented Programming & Classes](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/oop_classes.md)
56+
57+
58+
## 5. `this`, `call` `apply`, `bind`
59+
60+
- HYF Fundamental - [What is 'this'?](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/this.md)
61+
- MDN - [Function.prototype.call()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
62+
- MDN - [Function.prototype.apply()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply)
63+
- MDN - [Function.prototype.bind()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
64+
65+
66+
## 6. Recommended Readings
67+
68+
[Eloquent JavaScript: Chapter 6 - The Secret Life of Objects](http://eloquentjavascript.net/06_object.html). Read up to the section of **Maps**.
3369

3470
_Please go through the material and come to class prepared!_

0 commit comments

Comments
 (0)