The location.params()
function (shown below) can be used as a getter or setter. Examples:
Given the URL is http://example.com/?foo=bar&baz#some-hash,
location.params()
will return an object with all the query parameters:{foo: 'bar', baz: true}
.location.params('foo')
will return'bar'
.location.params({foo: undefined, hello: 'world', test: true})
will change the URL to http://example.com/?baz&hello=world&test#some-hash.
Here is the params()
function, which can optionally be assigned to the window.location
object.