What is JavaScript Promise.resolve() Method and its Usage?

Are you wondering what JavaScript Promise.resolve() Method is and how to use it? Keep on reading!

In this article, we will discuss the Promise.resolve() method in JavaScript along with examples.

So without further ado, let’s get started!

What is JavaScript promise?

A JavaScript promise is an object that is used to handle asynchronous operations in JavaScript.

It represents the eventual completion (or failure) of an asynchronous operation and allows you to write asynchronous code in a more readable and manageable way.

Promises have three states:

✔ Pending

✔ fulfilled

✔ Rejected

If a promise is pending, the asynchronous operation is still in progress. When the operation is successfully completed, the promise becomes fulfilled, and if an error occurs, it becomes rejected.

What is Promise.resolved() JavaScript?

The Promise.resolve() method in JavaScript is a quick way to create and resolve a Promise. It returns a Promise object that is resolved with the given value.

Here’s how it works:

✔ If the input given to Promise.resolve() is already a promise, it simply returns the same promise.

✔ If the input has a then method (meaning it’s thenable), Promise.resolve() invokes the then method and takes on its state.

✔ If the input is neither a promise nor thenable, Promise.resolve() creates and returns a new Promise object that is immediately fulfilled with the given value.

Syntax

Promise.resolve(value)

Parameters

value

The value is the argument to be resolved by this Promise. It could also be a Promise or a thenable that needs to be resolved.

Return value

This method gives back a Promise that has been resolved with the provided value. If the given value was a promise itself, then that promise is returned instead.

Here’s an example:

let SamplePromise = Promise.resolve("Hi, Welcome to Itsourcecode!");

SamplePromise.then((value) => { ✅
  console.log(value); 
});

As you can see in our example, Promise.resolve() creates a new resolved promise with the value “Hi, Welcome to Itsourcecode!”

After that, we use the .then() to say what should happen when the promise resolves. And we use the console.log() to log the value to the console.

Here’s the output:

Hi, Welcome to Itsourcecode!

How to use Promise.resolved() method in JavaScript?

The Promise.resolve() method in JavaScript is used to return a Promise object that is resolved with a given value.

Here’s a step-by-step guide on how to use the Promise.resolve() method in JavaScript:

Step 1: Define a value

This can be any value you want your Promise to resolve with. It could be a string, number, object, etc.

If you pass a Promise or thenable (an object with a then method), Promise.resolve() will return that Promise or convert the thenable into a Promise.

let value = 'Hi, Welcome to Itsourcecode!';

Step 2: Create a resolved Promise

Use Promise.resolve() to create a Promise that is resolved with the value you defined.

let promise = Promise.resolve(value);

Step 3: Handle the resolved Promise

Use the .then() method to specify what should happen when the Promise resolves. The .then() method takes a function as an argument, and this function will be called with the resolved value.

promise.then((resolvedValue) => {
console.log(resolvedValue);
});

And that’s it! You’ve created and handled a resolved Promise using Promise.resolve().

Output:

Hi, Welcome to Itsourcecode!

Please note that, Promises are a way to handle asynchronous operations in JavaScript, so they’re often used when dealing with operations that take some time to complete, like fetching data from an API.

Conclusion

In conclusion, we’ve explored the Promise.resolve() method in JavaScript, which is a quick and efficient way to create a Promise that is immediately resolved with a given value.

This method is particularly useful when dealing with asynchronous operations, which are common in JavaScript.

We’ve learned that a Promise in JavaScript represents the eventual completion (or failure) of an asynchronous operation and can be in one of three states: pending, fulfilled, or rejected.

We’ve gone through an example of how to use Promise.resolve(), from defining a value and creating a resolved Promise, to handling the resolved Promise using the .then() method.

We hope this article has provided you with enough information to understand the JavaScript promise resolve.

If you want to explore more JavaScript topics, check out the following articles:

Thank you for reading Itsourcecoders 😊.

Frequently Asked Questions

Is JavaScript still worth learning in 2026?
Yes. JavaScript runs on 98% of websites for the front-end, dominates the back-end via Node.js, powers mobile apps through React Native, builds desktop tools through Electron, and is the scripting layer for most AI tooling (LangChain.js, OpenAI SDK, Vercel AI). Whether you target web, mobile, AI, or full-stack capstones, JavaScript is the broadest single language you can learn.
What is the difference between var, let, and const?
var is function-scoped, hoisted to the top of its scope, and can be redeclared, which leads to bugs in modern code. let is block-scoped (only visible inside the nearest {}) and can be reassigned. const is block-scoped and cannot be reassigned, although object contents can still mutate. Default to const for everything, switch to let only when you actually need to reassign, and avoid var in any code written after 2017.
Which JavaScript version should I target in 2026?
Target ES2020 (ES11) as the safe baseline because every modern browser and Node.js 14+ supports it fully. ES2022 adds useful features like top-level await, private class fields with the # prefix, and the .at() array method. If you are writing for older browsers (IE11 or older Android WebViews), transpile down with Babel or use a build tool like Vite, esbuild, or webpack.
What is the best free editor for JavaScript?
Visual Studio Code is the industry standard, free, with built-in IntelliSense, debugger, terminal, Git, and a huge extension marketplace (ESLint, Prettier, GitHub Copilot, Tailwind). Install the JavaScript and TypeScript Nightly extension for the latest language features. JetBrains WebStorm is more powerful and free for students with a verified .edu email. For quick scratchpad work, the Chrome DevTools Sources panel includes a workspace and breakpoint debugger.
How do I run JavaScript locally vs in the browser?
In the browser: open DevTools with F12 (or right-click then Inspect), go to the Console tab, type or paste your code, press Enter. For HTML pages, add a script tag pointing to your .js file. Locally with Node.js: download Node from nodejs.org (LTS version), then run node script.js in your terminal from the file folder. Use the same Node setup for backend capstones, API integrations, and scripts that do not need a browser.
What can I build with JavaScript for my BSIT capstone?
Common BSIT capstones in JavaScript: full-stack web apps using React or Vue on the front-end with Node.js and Express on the back-end (MongoDB or MySQL for the database), real-time chat or notification systems using Socket.io, single-page dashboards with Chart.js or D3.js, cross-platform mobile apps with React Native, AI-powered chatbots using OpenAI SDK and LangChain.js, and Chrome extensions for productivity tools. Add Tailwind CSS for the UI and Vercel or Netlify for free deployment.

Leave a Comment