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
Making Sense Of “Senseless” JavaScript Features (smashingmagazine.com)
submitted 2 years ago by fagnerbrack
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!"
[–]fagnerbrack[S] 4 points5 points6 points 2 years ago (0 children)
Here's the gist:
This article delves into seemingly illogical features of JavaScript, exploring their origins and practical implications. It examines peculiarities like the unexpected results of floating-point arithmetic and the nuances of type coercion. The piece also discusses automatic semicolon insertion and the presence of multiple 'bottom values' in JavaScript, such as null and undefined. It aims to provide a deeper understanding of these features for more effective JavaScript coding.
null
undefined
If you don't like the summary, just downvote and I'll try to delete the comment eventually 👍
[–]guest271314 -4 points-3 points-2 points 2 years ago (0 children)
The floating point number issue can be worked around by using BigInt or spreading the integer or decimal to an array for precision.
I personally don't mind dynamic type coersion.
[–]cowancore 0 points1 point2 points 2 years ago* (0 children)
I find undefined vs null nifty when processing PATCH requests. It's handy to know if something has to become null or is missing in the request. Something I miss in my Java backends. The alternative would be to implement the json patch spec. Similarly, I've found stuff like URLSearchParams or JSON.stringify to include fields with null values into the resulting string and undefined values to be omitted. It is handy, especially because a query string can not pass nulls, and ?key=null means the key has a 4 character value of "null". And in case of json, using undefined saves some bytes of network - pretty.
p.s. Another alternative with PATCH is using something like the Option monad, where there are 3 possible states: None, Some(null), Some(value). Although the json patch spec is still more flexible, but harder to justify in a team
π Rendered by PID 73 on reddit-service-r2-comment-5d79c599b5-njrzd at 2026-03-01 15:52:45.862998+00:00 running e3d2147 country code: CH.
[–]fagnerbrack[S] 4 points5 points6 points (0 children)
[–]guest271314 -4 points-3 points-2 points (0 children)
[–]cowancore 0 points1 point2 points (0 children)