Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 2018-07-23-url-search-params.md #99

Merged
merged 1 commit into from
Jul 26, 2018
Merged

Update 2018-07-23-url-search-params.md #99

merged 1 commit into from
Jul 26, 2018

Conversation

oliverturner
Copy link
Contributor

Ohai!
Loved the article :)
This is completely speculative, so please reject at will, but thought it might be worth demonstrating that

  • As well as using window.location.search you can generate URL objects from scratch with new URL("https://..."): very handy for working with APIs when paired with the URLSearchParams API.

    Possibly obvious to some, but not to all (especially newcomers)

  • ...params.entries() is another way to iterate the parameters, having the advantage that it combines both key and value in the same iteration (i.e. no need to look up the value using the key)

Ohai! 
Loved the article :)
This is *completely* speculative, so please reject at will, but thought it might be worth demonstrating that

- As well as using `window.location.search` you can generate URL objects from scratch with `new URL("https://...")`: very handy for working with APIs when paired with the `URLSearchParams` API. 

  Possibly obvious to some, but not to all (especially newcomers)

- `...params.entries()` is another way to iterate the parameters, having the advantage that it combines both key and value in the same iteration (i.e. no need to look up the value using the key)
@jackfranklin
Copy link
Owner

This is amazing, thank you!

@jackfranklin jackfranklin merged commit badb042 into jackfranklin:master Jul 26, 2018
@oliverturner oliverturner deleted the patch-1 branch July 26, 2018 20:18
@oliverturner
Copy link
Contributor Author

Any time! Learned some interesting things from you, delighted to be able to give a little back :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants