Home / javascript / Simple JavaScript code in promises.

Simple JavaScript code in promises.

function promiseExample(){
    const promise = new Promise((resolve, reject) =>{
            resolve('successfully!');
    })
    .then((resolve) => console.log(resolve))
    .catch((reject) => console.log(reject));
  return promise;
}
promiseExample()

I have a create simple code example for promises. you can easily check. how to resolve is working? and how to reject is working?

About admin

Check Also

What is hoisting in javascript with example?

Hoisting in JavaScript is a behavior where variable and function declarations are moved to the …

Leave a Reply

Your email address will not be published. Required fields are marked *