I have following code snippets:
const x = () => {
return Promise.resolve("X1");
};
x().then((message) => {
console.log(message);
});
vs
const y = new Promise((resolve, reject) => {
resolve("Y1");
});
y.then((message) => {
console.log(message);
});
I understand the resolve in the second code snippet is like callback. Not sure about the first one, under what cases we need call Promise.resolve?