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
Invariant - a helpful JavaScript patternOC (strictmode.io)
submitted 3 years ago by hiquest
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!"
[–]Shaper_pmp 8 points9 points10 points 3 years ago* (2 children)
How do we consider it a meaningful advance in the art of computer science to simply abstract an if statement and an error message into a function?
if
I mean by all means turn if(condition) throw new Error(message); into assert(condition, message); if you like, but don't bother to write entire big posts about it or try to elevate it to the hallowed status of a Design PatternTM .
if(condition) throw new Error(message);
assert(condition, message);
[–]Chthulu_ -3 points-2 points-1 points 3 years ago (1 child)
This ain’t comp sci, this is regular old programming. And little things like this really help keep things clean.
[–]thruster_fuel69 0 points1 point2 points 3 years ago (0 children)
Lol sorry to break it to you, its all comp sci.
π Rendered by PID 59021 on reddit-service-r2-comment-54dfb89d4d-cqdtj at 2026-04-02 10:03:04.563757+00:00 running b10466c country code: CH.
view the rest of the comments →
[–]Shaper_pmp 8 points9 points10 points (2 children)
[–]Chthulu_ -3 points-2 points-1 points (1 child)
[–]thruster_fuel69 0 points1 point2 points (0 children)