Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

URLSearchParams.append(): adding query parameters

append(name, value) adds a pair at the end of the query parameters, preserving earlier values with the same name.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

params.append(name, value)

params.append(name, value) mutates the object and returns undefined, so calls cannot be chained. Both arguments are required.

append() preserves duplicates and order. get() reads the first value; getAll() reads all values. By contrast, set() replaces the first value and removes others with that name.

Pass unencoded text. toString() uses application/x-www-form-urlencoded encoding: a space becomes +, and a literal + becomes %2B; the result excludes ?. Calling through url.searchParams updates the associated URL. This Web API is defined by the URL Standard, not ECMAScript itself.

Examples

const params = new URLSearchParams("tag=web");
const result = params.append("tag", "JavaScript basics");
console.log(params.toString());
console.log(JSON.stringify(params.getAll("tag")));
console.log(result);

Result

tag=web&tag=JavaScript+basics
["web","JavaScript basics"]
undefined

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources