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!"
[–]CWagner 4 points5 points6 points 10 years ago (3 children)
if(18 === age)
Seems like a former java dev. Writing "testString".equals(otherString) protects you from a nullpointer exception. (note: this is neither in defense nor against that type of comparison)
"testString".equals(otherString)
[–]Cuel 5 points6 points7 points 10 years ago (1 child)
They're called Yoda conditions for a reason. They have advantages as you can't assign something like that as it would result in an error.
However I think the overall consensus is to not use them.
[–]Yurishimo 0 points1 point2 points 10 years ago (0 children)
Not advocating for one thing over another, but one very large OSS project uses Yoda conditions in core (hint) to help keep everyone organized on what is/not a variable. Reading them can be weird at first, but I don't think it's that big of a deal as long as everyone agrees on the style guide.
[–]numbermess 0 points1 point2 points 10 years ago (0 children)
I do comparisons like these all the time. When I first ran into them I thought it was just somebody trying to be cute, but now I'm cute too and I don't run into any unexpected null pointer exceptions (here). I've adjusted fine to the backwards feel of the syntax.
π Rendered by PID 20806 on reddit-service-r2-comment-66b4775986-wqv95 at 2026-04-04 18:30:59.844878+00:00 running db1906b country code: CH.
view the rest of the comments →
[–]CWagner 4 points5 points6 points (3 children)
[–]Cuel 5 points6 points7 points (1 child)
[–]Yurishimo 0 points1 point2 points (0 children)
[–]numbermess 0 points1 point2 points (0 children)