Created
September 25, 2013 23:55
-
-
Save lfender6445/6707904 to your computer and use it in GitHub Desktop.
jQuery convert query string to json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query_to_hash = function() { | |
var j, q; | |
q = window.location.search.replace(/\?/, "").split("&"); | |
j = {}; | |
$.each(q, function(i, arr) { | |
arr = arr.split('='); | |
return j[arr[0]] = arr[1]; | |
}); | |
return j; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
improved above with es6 and decode uri param, also always return in array.reduce, also replacing only starting ? and in any param