Is there a better way to convert a URL\'s location.search as an object? Maybe just more efficient or trimmed down? I\'m using jQuery, but pure JS can work too.
My approach, simple and clean
var params = "?q=Hello World&c=Awesome"; params = "{\"" + params .replace( /\?/gi, "" ) .replace( /\&/gi, "\",\"" ) .replace( /\=/gi, "\":\"" ) + "\"}"; params = JSON.parse( params ); alert( decodeURIComponent( params.q ) ); alert( decodeURIComponent( params.c ) );