How do I use a variable in a hyperlink?

I have the link: login-register.html?location=login

I want to use the location variable which in that link equals login. How do I get that variable in javascript when I’m in login-register.html

Let me know if you need more info!