In this tutorial we are going to show you how to parse a URL and get values from the URL that you are passed.
Just have a look at the following simple code.
var query = URL.split('?').split('&');
var pair = key.split('=');
alert(pair + '=' + pair);
URL will be split into parts based on the type of separators you are given in the function.
In this example we gave (‘?’, ‘&’)
In forEach loop we are checking for the key and value pairs.
Those should be
key1 = firstValue
value1 = name
key2 = secondValue
value2 = email
We are alerting the result that generated here.
For any queries please comment in the bellow comment section.
For more interesting and useful code snippets please follow our blog.