pastebin

Paste Search Dynamic
Recent pastes
url searchParams
  1. let url = new URL('https://bing.com/search');
  2. url.searchParams.set('q', 'test me!'); // added parameter with a space and !
  3. alert(url); // https://bing.com/search?q=test+me%21
  4. url.searchParams.set('tbs', 'qdr:y'); // added praameter with a colon :
  5. // parameters are automatically encoded
  6. alert(url); // https://bing con/search?q=test+me%21&tbs=qdr%3Ay
  7. // iterate over search parameters (decoded)
  8. for(let [name, value] of url.searchParams) {
  9.   alert(`${name}=${value}`); // q=test me!, then tbs=qdr:y
  10. }
Parsed in 0.005 seconds