Skip to content

Commit 8346b54

Browse files
authored
URLSearchParams snippet
1 parent bf89592 commit 8346b54

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,22 @@ const user = {
196196
const { education : { degree } }
197197
console.log(degree) //Masters
198198
```
199+
200+
# URLSearchParams
201+
202+
203+
```javascript
204+
//The URLSearchParams interface defines utility methods to work with the query string of a URL.
205+
206+
const urlParams = new URLSearchParams("?post=1234&action=edit");
207+
208+
console.log(urlParams.has('post')); // true
209+
console.log(urlParams.get('action')); // "edit"
210+
console.log(urlParams.getAll('action')); // ["edit"]
211+
console.log(urlParams.toString()); // "?post=1234&action=edit"
212+
console.log(urlParams.append('active', '1')); // "?post=1234&action=edit&active=1"
213+
```
214+
215+
216+
217+

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy