Skip to main content
URLSearchParams.prototype.forEach - node__url.d.ts - Node documentation
method URLSearchParams.prototype.forEach

Usage in Deno

```typescript import { URLSearchParams } from "node:node__url.d.ts"; ```
URLSearchParams.prototype.forEach<TThis = this>(
fn: (
this: TThis,
value: string,
name: string,
searchParams: URLSearchParams,
) => void
,
thisArg?: TThis,
): void
Iterates over each name-value pair in the query and invokes the given function. ```js const myURL = new URL('https://example.org/?a=b&c=d'); myURL.searchParams.forEach((value, name, searchParams) => { console.log(name, value, myURL.searchParams === searchParams); }); // Prints: // a b true // c d true ```

Type Parameters

TThis = this

Parameters

fn: (
this: TThis,
value: string,
name: string,
searchParams: URLSearchParams,
) => void
Invoked for each name-value pair in the query
optional
thisArg: TThis
To be used as `this` value for when `fn` is called

Return Type

void