A promise represents the completion of an async function. It is an object which will return a value.
You can initialize a promise with "new Promise" syntax, and it is initialized with a function. Function gets passed to a promise has "resolve" and "reject" parameters, which handles the success and failure of an operation respectively.
Example:-
// Initialize a promise:-
const promise = new Promise((resolve, reject) => {})
// If we inspect the promise above, we would get:-
proto: Promise
[[PromiseStatus]]: "pending"
[[PromiseValue]]: undefined
When a value is given to the promise:-
const promise = new Promise((resolve, reject) => {
resolve('We did it!')
})
// Now we will inspect the promise above, we would get:-
proto: Promise
[[PromiseStatus]]: "fulfilled"
[[PromiseValue]]: "We did it!"
As I had said, promise is an object that may return a value. After being successful it goes from undefined to being populated with data.