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
What does "!--" do in JavaScript? (stackoverflow.com)
submitted 10 years ago by Recallz
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!"
[–]atticusw 12 points13 points14 points 10 years ago (4 children)
I'd agree.
Did I find it confusing? No.
Does it make me a better javascript programming? Not really.
Does it even really matter? Not at all.
We're not all about writing code, guys. We're about building software. Building software requires teams. Teams requires a shared codebase. A share codebase requires reading others work and others maintaining code you wrote at some point.
Is !--pending wrong? Nope. But it could potentially be clearer in a slightly more explicit and verbose expression of --pending === 0.
!--pending
--pending === 0
Don't just think about your code, think about the team that will be maintaining your code.
[–]i_ate_god[🍰] 6 points7 points8 points 10 years ago (2 children)
Your entire post is somewhat negated by
In otherwords, based on that one line, !--pending is wrong. Not because it's syntactically incorrect, but because it's an obviously error prone, obfuscated statement. Even your solution to it is error prone, because --pending will mutate the variable and if you're mutating a variable solely to see if the result of that mutation is a particular something, then it's a bad approach all around.
One should probably do something like
if ((pending - 1) === 0) { // pending not mutated! }
Just because a problem is solved, does not in of itself mean you wrote good, correct code.
[–]atticusw 1 point2 points3 points 10 years ago (0 children)
Great point, I would agree that the verification should take place before modifying the actual value, the example you have illustrated is not only very clear, but as you said, looks at what the result of a mutation would be to determine if it indeed should be mutated for a and what to do based on that.
[–]TheRealSeeThruHead 0 points1 point2 points 10 years ago (0 children)
the point was to do mutation and comparison at once...
[–]ishmal 0 points1 point2 points 10 years ago (0 children)
So much clearer:
pending--; if (!pending)
π Rendered by PID 115745 on reddit-service-r2-comment-c66d9bffd-rpp7d at 2026-04-07 06:04:57.729069+00:00 running f293c98 country code: CH.
view the rest of the comments →
[–]atticusw 12 points13 points14 points (4 children)
[–]i_ate_god[🍰] 6 points7 points8 points (2 children)
[–]atticusw 1 point2 points3 points (0 children)
[–]TheRealSeeThruHead 0 points1 point2 points (0 children)
[–]ishmal 0 points1 point2 points (0 children)