MDN Web Docs

Syntax

js

append(name, value)

Parameters

name

The name of the parameter to append.

value

The value of the parameter to append.

Return value

None (undefined).

Examples

Adding the same parameter multiple times

js

const url = new URL("https://example.com?foo=1&bar=2");
const params = new URLSearchParams(url.search);
// Add a second foo parameter.
params.append("foo", 4);
// Query string is now: 'foo=1&bar=2&foo=4'

Specifications

Specification
URL
# dom-urlsearchparams-append

Browser compatibility

See also

Help improve MDN

Yes No

Learn how to contribute

This page was last modified on by MDN contributors.

Read the original on developer.mozilla.org ↗