URLSearchParams.toString()

This translation is incomplete. Please help translate this article from English

toString() URLSearchParams 인터페이스의 메소드로서, URL에서 사용할 수 있는 쿼리 문자열을 리턴합니다.

Note: 이 메소드는 물음표가 없는 쿼리 문자열을 리턴합니다. 이는 물음표를 포함하여 리턴하는 window.location.search와는 다른 부분입니다.

주의: 이 기능은 Web Worker에서 사용할 수 있습니다.

Syntax

URLSearchParams.toString()

Parameters

None.

Return value

A DOMString, without the question mark.

Examples

let url = new URL('https://example.com?foo=1&bar=2');
let params = new URLSearchParams(url.search.slice(1));

//두번째 foo 파라미터를 추가합니다.
params.append('foo', 4);
console.log(params.toString());
//'foo=1&bar=2&foo=4'를 출력합니다.

// note: params can also be directly created
let url = new URL('https://example.com?foo=1&bar=2');
let params = url.searchParams;

// or even simpler
let params = new URLSearchParams('foo=1&bar=2');

Specifications

Specification Status Comment
URL
The definition of 'toString() (see "stringifier")' in that specification.
Living Standard Initial definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
toStringChrome Full support 49Edge Full support 17Firefox Full support 29IE No support NoOpera Full support 36Safari Full support YesWebView Android Full support 49Chrome Android Full support 49Firefox Android Full support 29Opera Android Full support 36Safari iOS Full support YesSamsung Internet Android Full support 5.0

Legend

Full support  
Full support
No support  
No support

See also