Async and Ajax Flashcards

1
Q

What is a promise?

A

An object that represents a task that will be completed in the future.

It’s similar to getting a ticket at the deli meat counter. The ticket is a promise that you will get help, and stepping up to the counter and being helped is like your callback being invoked.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What parameters does a Promise take?

A

The Promise constructor takes a single argument - a callback function with two parameters: resolve and reject.

Resolve fires in event of success.

Reject fires in event of failure.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you use a Promise?

A

With Promise’s then() method.

Then takes two arguments - a success callback and a failure callback, but you can choose to provide only one or the other.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly