JavaScriptintermediate

Promise

A JavaScript object that represents a value that will arrive in the future — like a receipt for pending data.

Detailed Explanation

A Promise is JavaScript's way of handling operations that take time — API calls, file reads, database queries. Instead of blocking your code while waiting, a Promise says "I'll give you the result later."

A Promise has three states: pending (still waiting), fulfilled (got the result), and rejected (something failed). You handle results with .then() and errors with .catch(), or more commonly with async/await syntax which makes Promise-based code read like normal code.

Under the hood, every time you write await supabase.from('posts').select(), you're awaiting a Promise. Try/Catch blocks handle Promise rejections gracefully. Promises are the foundation of asynchronous JavaScript.

Free forever

Start building software you actually own.

Learn the concepts, fix things with confidence, and ship real products with AI beside you. No coding background required, and we're with you from the first idea to launch.

Free to start. No card. Leave whenever you want.