JS Built-ins
URLSearchParamsintermediate

URLSearchParams#forEach() β€” iterate with callback

πŸ“– Usage Example
const p = new URLSearchParams('a=1&b=2')
[...p.entries()]  // β†’ [['a','1'],['b','2']]

entries() returns an iterator of [key, value] pairs identical to the default iterator.

URLSearchParams#forEach()

params.forEach(callback) calls the callback for each entry with (value, key, params).

Challenge: Use forEach() to collect all keys.

πŸ’‘ Hints (1)
  • β€’ The callback receives (value, key, searchParams) β€” note value comes first