Promise creation :

function fetchData(url) {
	return new Promise((resolve, reject) => {
		console.log("started.");
		setTimeout(() => {
			resolve("success..");
		}, 4000);
		console.log(" promise ended but it is not fulfiiled..");
	});
}
fetchData("[www.google.com](<http://www.google.com/>)")

Explanation: "started" on console and it reaches to setTimeout method, then setTimeout is registered in the web environment and starts its timer. Execute the remaining code and return the promise object, but its state is pending and the value is undefined. After some time promise is fulfilled, then the promise state is updated from pending to fulfilled, and the value is the actual value.

Note: Creation of a promise involves a synchronous piece of code; it will wait, otherwise it won't wait.

let promise= fetchData("[www.google.com](<http://www.google.com/>)")
	let otherPromise = promise.then((value)=>{
		return "shivaji"
	})
	otherPromise.then((value)=>{
		console.log("the otherPromise value is ", value)
})

promise.resolve() : this method gives the fulfilled promise(resolved). you can chain with .then() method.

snippet 1 :