This function, available in windows and workers, allows developers to report errors to the console and any global "error" event handlers, in the same way as an uncaught JavaScript exception. It is mainly useful for custom event-dispatching or callback-manipulating libraries.
This allows library developers to report exceptions in the same way the browser does, which is useful when they need more custom control over running the callback. See https://esdiscuss.org/topic/a-way-of-explicitly-reporting-exceptions and https://github.com/whatwg/html/pull/1196#issuecomment-854177687 for examples.
Explainers: https://github.com/whatwg/console/issues/50