Keeping promises is asynchronous, which means it is executed, but the program will not wait until it finishes to continue working with the rest of the code.
Basically, your code does the following:
- Hello Magazine
- Create a promise
- Keeping a promise
- Zami magazine
- The promise is permitted and recorded there.
If you want it to print "Hello, zami", you need to
myPromise.then(function (result) { // Resolve callback. console.log(result); console.log('zami'); }, function (result) { // Reject callback. console.error(result); });
source share