Guest User

Untitled

a guest
Dec 17th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. // Assuming "?post=1234&action=edit"
  2.  
  3. const urlParams = new URLSearchParams(window.location.search);
  4.  
  5. console.log(urlParams.has('post')); // true
  6. console.log(urlParams.get('action')); // "edit"
  7. console.log(urlParams.getAll('action')); // ["edit"]
  8. console.log(urlParams.toString()); // "?post=1234&action=edit"
  9. console.log(urlParams.append('active', '1')); // "?post=1234&action=edit&active=1"
Add Comment
Please, Sign In to add comment