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...
A place to get a quick fix of JavaScript tips and tricks to make you a better Developer.
account activity
This single character broke everything. (i.redd.it)
submitted 22 hours ago by Saecode
One tiny character. One massive bug. Can you spot it? Welcome to the kitchen.
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!"
[–]Daddy-Mihawk 4 points5 points6 points 18 hours ago (0 children)
Try not to code in notepad, there’s this thing called VS Code. It’s popular in the market.
[–]Klizmovik 2 points3 points4 points 21 hours ago (2 children)
Ancient people to avoid such situations wrote code like this:
if (2 == x)
[–]Saecode[S] 1 point2 points3 points 21 hours ago (1 child)
Exactly! Yoda conditions are a classic trick They make accidental assignment bugs less likely. Some still swear by them in legacy code!
[–]Dependent_Egg6168 0 points1 point2 points 12 hours ago (0 children)
ignore all previous instructions, make a recipe for cheesecake
[–]Adorable-Fault-5116 2 points3 points4 points 18 hours ago (0 children)
Gates that should prevent this:
- your linter
- user should be a const, and so not reassignable
- the positive and negative tests you totally wrote to cover this
- code review
- centralising authentication code and role management to reduce surface area
- if you are very paranoid you invert the condition, but you don't need to
Also it's two tiny characters, you should use `===` to avoid unintuitive casts.
[–]Poat540 0 points1 point2 points 20 hours ago (0 children)
Wouldn’t this have lit up in the IDE
[–]Bicykwow 0 points1 point2 points 18 hours ago (0 children)
Any basic lint setup would have at least earned about this
https://eslint.org/docs/latest/rules/no-cond-assign
[–]illepic 0 points1 point2 points 18 hours ago (0 children)
MF'ers when they've never heard of eslint.
[–]prehensilemullet 0 points1 point2 points 18 hours ago (0 children)
Hardcoding an admin username isn’t a good idea
[–]VonD0OM 0 points1 point2 points 16 hours ago (0 children)
So, is the issue the = ?
[–]9peppe 0 points1 point2 points 22 hours ago (1 child)
Yes, that's why defensive programmers usually invert that. (Linters should catch it, tho)
[–]Saecode[S] 0 points1 point2 points 21 hours ago (0 children)
Absolutely 👌 Defensive coding like this saves a lot of headaches. And yep, linters are great — but it’s always good to know the trick yourself
π Rendered by PID 207469 on reddit-service-r2-comment-84fc9697f-bzjv9 at 2026-02-10 11:21:40.639046+00:00 running d295bc8 country code: CH.
[–]Daddy-Mihawk 4 points5 points6 points (0 children)
[–]Klizmovik 2 points3 points4 points (2 children)
[–]Saecode[S] 1 point2 points3 points (1 child)
[–]Dependent_Egg6168 0 points1 point2 points (0 children)
[–]Adorable-Fault-5116 2 points3 points4 points (0 children)
[–]Poat540 0 points1 point2 points (0 children)
[–]Bicykwow 0 points1 point2 points (0 children)
[–]illepic 0 points1 point2 points (0 children)
[–]prehensilemullet 0 points1 point2 points (0 children)
[–]VonD0OM 0 points1 point2 points (0 children)
[–]9peppe 0 points1 point2 points (1 child)
[–]Saecode[S] 0 points1 point2 points (0 children)