- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 0
url search params
        Nicholas Berlette edited this page Jun 19, 2025 
        ·
        1 revision
      
    function isURLSearchParams(it: unknown): it is URLSearchParams;Checks if a value is a URLSearchParams object.
This function is useful for checking if a value is an instance of the native
URLSearchParams class, without leaning on the instanceof operator (which
known to be unreliable in certain environments and across different realms).
| Name | Info | 
|---|---|
| it | The value to check. | 
true if the value is a URLSearchParams object, false otherwise.
Web APIs
import { isURLSearchParams } from "jsr:@nick/is/url-search-params";
console.log(isURLSearchParams(new URLSearchParams())); // true
console.log(isURLSearchParams(new URLSearchParams("a=1&b=2"))); // true
console.log(isURLSearchParams(new URL("https://foobar.com?a=1").searchParams)); // true
console.log(isURLSearchParams({})); // false
console.log(isURLSearchParams(new URL("data:"))); // false