Understanding JavaScript Promise - Codeuptoday
Promises in JavaScript are used to handle asynchronous operations. Let’s walk through what they are and test some examples live. 📘 Basic Promise Example This promise resolves after 2 seconds: const promise = new Promise((resolve, reject) => { setTimeout(() => { resolve("✅ Promise resolved!"); }, 2000); }); promise.then(result => console.log(result)); Run Example ❌ Promise Rejection