Created
January 27, 2012 17:01
-
-
Save maxterry/1689788 to your computer and use it in GitHub Desktop.
Naive memoized query param lookup
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
function param(key) { | |
var params = {} | |
window.location.search.substr(1).split("&").forEach(function(it) { | |
var slots = it.split("=") | |
params[slots[0]] = slots[1] == "true"? true : | |
slots[1] == "false"? false : | |
slots[1] | |
}) | |
param = function(key) { | |
return params[key] | |
} | |
return param(key) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment