JS3: Attendance and activity¶
FP¶
map(), filter(), and reduce() are so called higher-order functions? What does it mean?
Functions are the first-class citizens. What does this mean - give an example
Functions can be declarations or expressions. Please explain the following snippet:
const numbers = [1, 2, 3, 4]; const addFive = (numbers) => [...numbers, 5] addFive(numbers);
Async: Promise¶
What is the purpose of the two parameters in the Promise constructor’s callback argument?
const promise1 = new Promise((resolve, reject) => { resolve('Success!'); });
How do you get the return value of a resolved Promise?
What do we mean by “happy path” in the context of a promise chain?
How would you get access to the rejected value ‘Fail!’? There are multiple alternatives - itemize
const promise2 = new Promise((resolve, reject) => { reject('Fail!'); });
Can the Promise chain be continued after catch()? Give a rationale
Async: Fetch¶
fetch() is AJAX enabler. What is AJAX - why do we need it?
What is a query string? What is the separator between key-value pairs?
What HTTP method benefits from query string? What are the other HTTP methods?
Why does fetch() return a Promise? What does async keyword signify?
What implications are there if you await fetch() to finish?