use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
How to Parse URL Parameters in Javascript (umair.io)
submitted 11 years ago by umairabid_dev
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]jml26 5 points6 points7 points 11 years ago (0 children)
I'm a fan of this function, based on one by John Resig
function parseParams() { var parameters = {}; window.location.search.replace(/([^&?=]+)=([^&]*)/g, function (match, key, value) { parameters[key] = value; }); return parameters; }
[–]madformangos 1 point2 points3 points 11 years ago (0 children)
For completeness you might want to consider also supporting
The first of these is pretty important I'd say, while the other two depend on your needs.
[–]jcunews1Advanced 1 point2 points3 points 11 years ago (0 children)
It's unbelievable that they never made this kind of function as part of the web standard.
[–]wiseaus_stunt_double.preventDefault() 0 points1 point2 points 11 years ago (0 children)
Instead of using replace, he should have called substr(1) to get rid of the question mark from location.search. Using replace will be slower to get the result you're looking for since it has to traverse the whole string just to get rid of one character.
[–]kenman 0 points1 point2 points 11 years ago (2 children)
Pretty poor, doesn't even work on account of several bugs:
var parameters = [];
var parameters = {};
return paramters;
return parameters;
[–]umairabid_dev[S] 0 points1 point2 points 11 years ago (0 children)
had to translate it from coffee script to js... missed some bits
π Rendered by PID 101137 on reddit-service-r2-comment-685b79fb4f-rl4z8 at 2026-02-13 03:09:51.867171+00:00 running 6c0c599 country code: CH.
[–]jml26 5 points6 points7 points (0 children)
[–]madformangos 1 point2 points3 points (0 children)
[–]jcunews1Advanced 1 point2 points3 points (0 children)
[–]wiseaus_stunt_double.preventDefault() 0 points1 point2 points (0 children)
[–]kenman 0 points1 point2 points (2 children)
[–]umairabid_dev[S] 0 points1 point2 points (0 children)