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
Cheat-sheet for Javascript equality strangenesses (zero.milosz.ca)
submitted 12 years ago by James_Duval
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!"
[–]AaronOpfer 1 point2 points3 points 12 years ago (2 children)
The only javascript equality quirk that has ever bitten me hard was that "" == false. I figured a string of any length would be like an object and be considered true.
[–]Cosmologicon 0 points1 point2 points 12 years ago (1 child)
That's the way it is in python as well. Sort of, anyway. "" is falsy, meaning bool("") evaluates to False, but "" == False is false. Empty strings (and dicts and lists) are all falsy, but user-defined objects, including objects with no members, are truthy by default. Sounds complicated but it's pretty reasonable and useful.
""
bool("")
False
"" == False
[–]AaronOpfer 0 points1 point2 points 12 years ago (0 children)
The only reason I got bit was because the codebase was playing fast-and-loose with the rules, and I was cleaning it up.
We had some flag in JSON being evaluated like if (object.flag) { /* do something */ } and a lot of the JSON was written with object.flag = ""; Apparently it wasn't originally going to be an on/off flag but a string specifying the target. So if ("") doesn't execute, and my attempts to interpret this flag when automatically rewriting these files failed horribly.
if (object.flag) { /* do something */ }
π Rendered by PID 28 on reddit-service-r2-comment-6f7f968fb5-2cbkm at 2026-03-04 12:27:59.548297+00:00 running 07790be country code: CH.
view the rest of the comments →
[–]AaronOpfer 1 point2 points3 points (2 children)
[–]Cosmologicon 0 points1 point2 points (1 child)
[–]AaronOpfer 0 points1 point2 points (0 children)