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 #
#
const myURL = new URL('https://example.org/foo?bar=baz');
console.log(myURL.search); // Logs "?bar=baz"
const myOtherURL = new URL('https://example.org/foo?bar=baz#quux');
console.log(myOtherURL.search); // Logs "?bar=baz"
Type #
string