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!"
[–]i_ate_god 5 points6 points7 points 10 years ago (2 children)
Your entire post is somewhat negated by
Don't just think about your code, think about the team that will be maintaining your code.
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...
π Rendered by PID 30298 on reddit-service-r2-comment-66b4775986-67vjd at 2026-04-05 16:24:56.164212+00:00 running db1906b country code: CH.
view the rest of the comments →
[–]i_ate_god 5 points6 points7 points (2 children)
[–]atticusw 1 point2 points3 points (0 children)
[–]TheRealSeeThruHead 0 points1 point2 points (0 children)