📜  javascript promise - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:39.079000             🧑  作者: Mango

代码示例6
// Promise is a special type of object that helps you work with asynchronous operations.
// Many functions will return a promise to you in situations where the value cannot be retrieved immediately.

const userCount = getUserCount();
console.log(userCount); // Promise {}

// In this case, getUserCount is the function that returns a Promise. If we try to immediately display the value of the userCount variable, we get something like Promise {}.
// This will happen because there is no data yet and we need to wait for it.