The window.location.search stores the query string of the URL including the question mark. With the above example URL, the value of window.location.search will be “?id=123456&name=amy”. Then we use the substring function to get rid of the question mark and then split the string into an array of param pairs. At this point, each element will be a string of varaible and value pairs connected with the equal sign(=). Next, loop through the array, split each variable and value pair by the equal sign and add them to the json object.