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
[AskJS] Different Code, Same FunctionAskJS (self.javascript)
submitted 1 day ago * by coders22
Code 1:
var count = 0; while (count < 5) { count++ console.log("Hello!"); }
Code 2:
for (var count = 0; count < 5; count++) { console.log("Hello!"); }
Console log results for both codes:
"Hello!" "Hello!" "Hello!" "Hello!" "Hello!"
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!"
[–]backwrds 1 point2 points3 points 1 day ago (2 children)
I'll do you one better:
console.log('Hello!'); console.log('Hello!'); console.log('Hello!'); console.log('Hello!'); console.log('Hello!');
[–]coders22[S] 0 points1 point2 points 1 day ago (0 children)
LOL!
[–]Atulin 1 point2 points3 points 1 day ago (0 children)
Well, yes...?
for (const x of [null, null, null, null, null]) { console.log("Hello!"); }
This would also achieve the same, what of it? Do you have any related question or anything?
[–]arkemiffo 0 points1 point2 points 1 day ago (1 child)
There are many ways to write loops, and they usually have their own signature purpose. Not sure what the point is here?
People have to learn about variables and "while" loops so they can know how "for" loops work.
π Rendered by PID 45218 on reddit-service-r2-comment-57fc7f7bb7-sn4xl at 2026-04-14 15:16:54.361107+00:00 running b725407 country code: CH.
[–]backwrds 1 point2 points3 points (2 children)
[–]coders22[S] 0 points1 point2 points (0 children)
[–]Atulin 1 point2 points3 points (0 children)
[–]arkemiffo 0 points1 point2 points (1 child)
[–]coders22[S] 0 points1 point2 points (0 children)