Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. URLSearchParams
  4. values()

URLSearchParams: values() method

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2018.

Note: This feature is available inWeb Workers.

Thevalues() method of theURLsearchParamsinterface returns aniterator allowing iterationthrough all values contained in this object. The values are strings.

Syntax

js
values()

Parameters

None.

Return value

Returns aniterator.

Examples

The following example passes a URL search string to theURLSearchParams constructor, then uses the iterator returned byvalues() to print the values to the console.

js
const searchParams = new URLSearchParams("key1=value1&key2=value2");for (const value of searchParams.values()) {  console.log(value);}

The result is:

value1value2

This example does much the same as above, but first casts the iterator into an array.

js
const searchParams = new URLSearchParams("key1=value1&key2=value2");console.log(Array.from(searchParams.values()));

The result is:

['value1', 'value2']

Specifications

Specification
URL
# dom-urlsearchparams-urlsearchparams

Browser compatibility

See also

  • TheURL interface.

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp