Language concepts

Thenable

Try the free JavaScript compiler

Object or function with a callable then property. Promise resolution invokes that method through a job and adopts its resulting outcome. It may fail or never settle.

Formal Syntax & Structure

javascript syntaxjavascript
{ then(resolve, reject) { /* ... */ } }

Working Example

Example Snippetjavascript
const value = { then(resolve) { console.log("then called"); resolve(6); } };Promise.resolve(value).then(console.log);console.log("sync");
JavaScript Reference