URLSearchParams

URLSearchParams.prototype.getAll

Returns all the values associated with a given search parameter as an array

Syntax

JavaScript
params.getAll(name)

Parameters

ParameterTypeDescription
namestringThe name of the parameter

Return Value

An array of strings

Examples

Basic Usage
const params = new URLSearchParams('tag=js&tag=ts&tag=react')
console.log(params.getAll('tag')) // ['js', 'ts', 'react']
Practical Example
const url = new URL('https://example.com?id=1&id=2&id=3')
const ids = url.searchParams.getAll('id').map(Number)
console.log(ids) // [1, 2, 3]
Advanced Usage
function getSelectedFilters(): string[] {
  const params = new URLSearchParams(window.location.search)
  return params.getAll('filter')
}

Understanding URLSearchParams.prototype.getAll

The URLSearchParams.prototype.getAll method in JavaScript returns all the values associated with a given search parameter as an array. It belongs to the URLSearchParams object and is one of the most widely used methods for working with urlsearchparams values in modern JavaScript and TypeScript applications.

The method signature is params.getAll(name). It accepts 1 parameter: name. When called, it returns an array of strings. Understanding when and how to use getAll() helps you write more expressive, readable code.

Common use cases for URLSearchParams.prototype.getAll include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like urlsearchparams-get, urlsearchparams-append, urlsearchparams-has, enabling you to chain operations together for complex data manipulation pipelines.

Browser support for URLSearchParams.prototype.getAll is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.

Browser Compatibility

Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.

Related Methods

More URLSearchParams Methods

Other methods in the URLSearchParams object

Related Tools

More URLSearchParams Methods

Explore JavaScript Methods

Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.