Skip to content

Instantly share code, notes, and snippets.

@maxterry
Created January 27, 2012 17:01
Show Gist options
  • Save maxterry/1689788 to your computer and use it in GitHub Desktop.
Save maxterry/1689788 to your computer and use it in GitHub Desktop.
Naive memoized query param lookup
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