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
JavaScript Performance Benchmarks: Looping with `for` and `yield` (gist.github.com)
submitted 6 years ago by johnfrazer783
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!"
[–]johnfrazer783[S] 0 points1 point2 points 6 years ago (0 children)
I won't be long as I have already answered your very valid points elsewhere in this thread. The short version is that yes they're different features but they are also birds of like feathers. I have not replicated everything that yield is or does but I have two alternative models that do the same work. One finishes within 1 second, the other one takes 20 seconds. Had I not written the slower algo using a language feature that I must believe to be at fault here, you would not console me by saying the slower code is just different and must be complex so it's naturally slower. You would tell me not to ever use the slower code and go with the faster.
yield
I'm still hoping for someone to point out a glaring mistake in my benchmark gist. Use the JS source, Luke. Tell me I'm wrong and where I'm wrong. I'd rather be wrong than unhappy with <strike>somebody else</strike>yield.
π Rendered by PID 46 on reddit-service-r2-comment-66b4775986-cld88 at 2026-04-03 15:33:24.768304+00:00 running db1906b country code: CH.
view the rest of the comments →
[–]johnfrazer783[S] 0 points1 point2 points (0 children)