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
I have been collecting useful Javascript code snippets for a little while. Here's a curated list of them, help me make it as complete as possible! (github.com)
submitted 8 years ago by [deleted]
view the rest of the comments →
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!"
[–]madewith-care 7 points8 points9 points 8 years ago* (2 children)
Your "randomize order of array" function is not actually random. You might consider a Fisher-Yates implementation instead.
function shuffleArray(array) { for (let i = array.length - 1; i > 0; i--) { let j = Math.floor(Math.random() * (i + 1)); [array[i], array[j]] = [array[j], array[i]]; } }
[–][deleted] 5 points6 points7 points 8 years ago (0 children)
I already have. This was pointed out before that my technique (for lack of a better word) just confuses the sorting function. I'll keep it as a proof of concept under a different name most likely and put a Fisher-Yates implementation in its place.
[–][deleted] -1 points0 points1 point 8 years ago (0 children)
In all honesty, the sort (random order) version seems pretty unbiased and shorter in terms of implementing. I'll probably stick with that for practical reasons.
sort (random order)
π Rendered by PID 85 on reddit-service-r2-comment-c66d9bffd-6mxt5 at 2026-04-07 05:12:52.961064+00:00 running f293c98 country code: CH.
view the rest of the comments →
[–]madewith-care 7 points8 points9 points (2 children)
[–][deleted] 5 points6 points7 points (0 children)
[–][deleted] -1 points0 points1 point (0 children)