URLSearchParams

URLSearchParams.prototype.append

Appends a specified key/value pair as a new search parameter, without removing existing ones with the same name

Syntax

JavaScript
params.append(name, value)

Parameters

ParameterTypeDescription
namestringThe name of the parameter
valuestringThe value to append

Return Value

undefined

Examples

Basic Usage
const params = new URLSearchParams()
params.append('tag', 'js')
params.append('tag', 'ts')
console.log(params.toString()) // 'tag=js&tag=ts'
Practical Example
const params = new URLSearchParams('color=red')
params.append('color', 'blue')
console.log(params.getAll('color')) // ['red', 'blue']
Advanced Usage
function addFilters(params: URLSearchParams, filters: string[]) {
  filters.forEach(f => params.append('filter', f))
  return params
}

Understanding URLSearchParams.prototype.append

The URLSearchParams.prototype.append method in JavaScript appends a specified key/value pair as a new search parameter, without removing existing ones with the same name. 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.append(name, value). It accepts 2 parameters: name, value. When called, it returns undefined. Understanding when and how to use append() helps you write more expressive, readable code.

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

Browser support for URLSearchParams.prototype.append 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.