Skip to main content
property URL.search

The search property of the URL interface is a string that represents the search string, or the query string, of the URL. This includes the ? character and the but excludes identifiers within the represented resource such as the URL.hash. More granular control can be found using URL.searchParams property.

Examples

Example 1

const myURL = new URL('https://example.org/foo?bar=baz');
console.log(myURL.search);  // Logs "?bar=baz"

Example 2

const myURL = new URL('https://example.org/foo?bar=baz#quux');
console.log(myURL.search);  // Logs "?bar=baz"

Type

See

Back to top