Web APIs

AbortController

Try the free JavaScript compiler

Creates a controller and its associated AbortSignal. Calling abort signals cooperative cancellation to interested operations. It does not forcibly terminate arbitrary code.

Formal Syntax & Structure

javascript syntaxjavascript
new AbortController()

Return Value

AbortController

Controller with a signal and abort method.

Working Example

Example Snippetjavascript
const c = new AbortController();c.signal.addEventListener("abort", () => console.log(c.signal.reason), {once:true});c.abort("stop"); c.abort("again");console.log(c.signal.aborted);
JavaScript Reference