What are JavaScript objects that represent the eventual result of an asynchronous operation?
Promises
What do we call a function that is passed as an argument to another function?
A callback function
What is the keyword that indicates an asynchronous function?
async
What does API stand for?
Application Programming Interface
What does the data-transfer format JSON stand for?
JavaScript Object Notation
What are the two possible outcomes of a promise that are built in?
resolve() and reject()
True or False: callback functions can handle both synchronous and asynchronous operations.
True
What keyword does this define:
An operator used only inside of an async function that halts the execution of a function until a given promise is no longer pending and returns the resolved value of the promise.
await
What is the modern API for making a request from our JavaScript?
The fetch() API
Using ______ JavaScript (such as callbacks, promises, and async/await), you can perform long network requests without blocking the main thread.
Asynchronous
We use _____ with a success handler callback containing the logic for what should happen if a promise resolves.
.then()
How would we call this function?
const printName = () => {
console.log("John");
}
printName();
In order to use the await keyword, we have to wrap it within a(n) _________ function.
Asynchronous
What type of HTTP method is used to read or retrieve a resource from an API?
GET
What does HTTP stand for?
Hypertext Transfer Protocol
We use _____ with a failure handler callback containing the logic for what should happen if a promise rejects.
.catch()
After how many seconds would this callback function run?
setTimeout(()=>console.log("Hello learners!"), 11000);
11
What will this code print to the console?
async function myFunction() {
return 'hello world';
}
myFunction()
.then((resolvedValue) => {
console.log(resolvedValue);
})
hello world
What type of data do GET and POST requests send and receive?
Objects
What built in JavaScript function sets a timer which executes a function or piece of code when the timer expires?
setTimeout()
What data type is the fulfilled value of Promise.all() ?
an Array
What would the following code be representing:
firstRequest(function(response) {
secondRequest(response,function(nextResponse) {
thirdRequest(nextResponse, function(finalResponse) {
console.log('Final response: ' + finalResponse);
}, failureCallback);
}, failureCallback);
}, failureCallback);
Callback Hell
When using a try {} block in an asynchronous function, what are the two possible statements needed after it? (One of the two is required, but there is two possibilities)
Catch and finally
What are the two possible parameters to a fetch statement? (First one is required, second one is optional)
The URL, and options or init object
What does an async function return?
async function example() { }
A promise