Web APIs

AbortSignal

Try the free JavaScript compiler

Object conveying cancellation state and reason, with an abort event. Signals can be shared with operations that accept them. An aborted signal does not reset.

Formal Syntax & Structure

javascript syntaxjavascript
controller.signal

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