Consider the following example:
In the example given above, only the first resolve()
call is executed. That means once a resolve()
or reject()
is executed, the promise is settled and any subsequent resolve()
or reject()
calls are ignored.
You might have noticed that the function passed as argument to the Promise
in the above example does not have any asynchronous operations. It is not necessary that the function passed as argument to a Promise
should contain asynchronous operations.