JS Built-ins
URLSearchParamsadvanced

URLSearchParams#getAll() β€” empty array fallback for missing keys

πŸ“– Usage Example
const p = new URLSearchParams()
p.set('q', 'hello world')
p.toString()  // β†’ 'q=hello+world'

URLSearchParams automatically encodes special characters in values.

URLSearchParams#getAll() β€” missing key fallback

params.getAll(name) always returns an array β€” even for keys that don't exist it returns [] (not null).

Challenge: Verify the distinction: get() returns null for missing keys, while getAll() returns [].

πŸ’‘ Hints (1)
  • β€’ getAll() always returns an array β€” use .length to check for presence instead of null checks