Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Assuming "?post=1234&action=edit"
- const urlParams = new URLSearchParams(window.location.search);
- console.log(urlParams.has('post')); // true
- console.log(urlParams.get('action')); // "edit"
- console.log(urlParams.getAll('action')); // ["edit"]
- console.log(urlParams.toString()); // "?post=1234&action=edit"
- console.log(urlParams.append('active', '1')); // "?post=1234&action=edit&active=1"
Add Comment
Please, Sign In to add comment