So what's the point of this whole post? Earlier today I created a js file that records metric information about website visitors... a pretty simple script... gather information such as screen resolution, user agent, color depth, ip address, session id, login id, etc and send it to a server side script to record the data.
So, one of the pieces I wanted to collect was the querystring. I wanted a clean one line solution to gathering that string.
I knew that window.location.href would give me the string version of the url currently in the browser so I thought I could split on the "?" resulting in "window.location.href.split('?')" Which in turn gave me an array containing 2 elements, the host string and the querystring... I am only interested in the query string... knowing that JS now treats the result as an array, I can grab the array element 1 (which is 2 in most programming languages...) like this: "window.location.href.split('?')"... and there I have it!