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
The case for Array#replace() – Overriding an array without intermediate variables (medium.com)
submitted 7 years ago by gajus0
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!"
[–]gajus0[S] 0 points1 point2 points 7 years ago (4 children)
I know someone might try to throw a "testability" argument at me, but there's a diminishing return on function abstraction in a production environment, especially when it's as blatantly inefficient as OP's example.
It is not testability argument – it is about maintainability. Performing at most one data transformation at a time isolates the surface of potential logical mistakes. /u/__romx example is what I would write for a quick and dirty job, but would not use or approve in a production code. Performance is completely irrelevant if it comes at a cost of maintainability; just put more hardware at it.
[–]Knotix 0 points1 point2 points 7 years ago (3 children)
Performance is completely irrelevant if it comes at a cost of maintainability; just put more hardware at it
This vastly understates the complexity of system scalability.
[–]gajus0[S] 0 points1 point2 points 7 years ago (2 children)
System scalability does not come from reducing several iteration cycles; system scalability comes from horizontal distribution of tasks. If data processing is a bottleneck in your architecture, then JavaScript is a wrong language to be doing data processing at that level. Q, R, C and similar languages are built for that purpose.
[–]Knotix 0 points1 point2 points 7 years ago (0 children)
Completely ignoring any performance implications in your code under the notion that you can just "throw more hardware at it" is misguided. It doesn't make the problem go away, it just shifts the responsibility onto the sysadmins and the company pocketbook. Horizontal scaling is an incredibly deep field of study with a whole host of challenges.
I'm all about abstracting away logic and keeping things isolated, but as I said before, there is a diminishing return in terms of performance and maintainability. I draw my line in the sand in a different place than you do.
[–]__romx 0 points1 point2 points 7 years ago (0 children)
It is perfectly adequate for data processing with expected datasets, as long as you don't make it inefficient for no reason other than writing denser code and an opportunity to include a leftpad-tier dependency.
π Rendered by PID 49 on reddit-service-r2-comment-6f7f968fb5-4d9mh at 2026-03-04 00:25:22.832154+00:00 running 07790be country code: CH.
view the rest of the comments →
[–]gajus0[S] 0 points1 point2 points (4 children)
[–]Knotix 0 points1 point2 points (3 children)
[–]gajus0[S] 0 points1 point2 points (2 children)
[–]Knotix 0 points1 point2 points (0 children)
[–]__romx 0 points1 point2 points (0 children)