URL.parse() vs new URL()

Type any URL — or pick a preset — to see what each API returns.

The key difference

new URL() Throws TypeError on invalid input. Correct when you control the string — the exception is a programmer-error signal.
URL.canParse() Returns true/false. Use when you only need validity, not the URL object — no allocation.
URL.parse() Returns a URL instance or null. Replaces every safeParseURL() wrapper.