Javascript Examples

Page 4 of 9

Browse Javascript examples

javascriptSnippet

AbortSignal Timeout Ends Slow Work

AbortSignal.timeout builds a deadline signal that aborts itself with a TimeoutError; wire it into slow work with throwIfAborted and one abort listener.

javascriptSnippet

padEnd Aligns Report Columns

padEnd left-aligns names while padStart right-aligns numbers, producing fixed-width report columns; over-wide values are never truncated.

javascriptSnippet

Reduce Folds Records Into A Map

Fold an array into a Map of per-key aggregates in one pass: the Map keeps first-seen order, and the object-spread version exposes a per-iteration copy trap.