Promises
Callbacks & Functions
Async Await
Requests
Potpourri
100

What are JavaScript objects that represent the eventual result of an asynchronous operation?

Promises

100

What do we call a function that is passed as an argument to another function?

A callback function

100

What is the keyword that indicates an asynchronous function?

async

100

What does API stand for?

Application Programming Interface

100

What does the data-transfer format JSON stand for?

JavaScript Object Notation

200

What are the two possible outcomes of a promise that are built in?

resolve() and reject()

200

True or False: callback functions can handle both synchronous and asynchronous operations.

True

200

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

200

What is the modern API for making a request from our JavaScript?

The fetch() API

200

Using ______ JavaScript (such as callbacks, promises, and async/await), you can perform long network requests without blocking the main thread.

Asynchronous

300

We use _____ with a success handler callback containing the logic for what should happen if a promise resolves.

.then()

300

How would we call this function?

const printName = () => {

console.log("John");

}

printName();

300

In order to use the await keyword, we have to wrap it within a(n) _________ function.

Asynchronous

300

What type of HTTP method is used to read or retrieve a resource from an API?

GET

300

What does HTTP stand for?

Hypertext Transfer Protocol

400

We use _____ with a failure handler callback containing the logic for what should happen if a promise rejects.

.catch()

400

After how many seconds would this callback function run?

setTimeout(()=>console.log("Hello learners!"), 11000);

11

400

What will this code print to the console?

async function myFunction() {
  return 'hello world';
}
myFunction()
.then((resolvedValue) => {
  console.log(resolvedValue);
})

hello world

400

What type of data do GET and POST requests send and receive?

Objects

400

What built in JavaScript function sets a timer which executes a function or piece of code when the timer expires?

setTimeout()

500

What data type is the fulfilled value of Promise.all() ?

an Array

500

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

500

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

500

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

500

What does an async function return?
async function example() { }

A promise