URLSearchParams: keys() method
URL API
URL API
The keys() method of the URLSearchParams
interface returns an iterator allowing iteration
through all keys contained in this object. The keys are strings.
Syntax
keys()
Parameters
None.
Return value
Returns an iterator.
Examples
// Create a test URLSearchParams object
const searchParams = new URLSearchParams("key1=value1&key2=value2");
// Display the keys
for (const key of searchParams.keys()) {
console.log(key);
}
The result is:
key1
key2
Specifications
Browser compatibility
See also
- The URL interface.