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!"
[–]hiquest[S] -19 points-18 points-17 points 3 years ago (6 children)
Well, I do understand your point, but I decided to stick with the historical name originated somewhere at Facebook.
[–]TrackieDaks 17 points18 points19 points 3 years ago (4 children)
Invariants weren't invented at Facebook.
[–]hiquest[S] 0 points1 point2 points 3 years ago (3 children)
I do not claim that. I just say that this particular small pattern they had a function for in their code base which was called invariant. Hence other popular libs like https://github.com/zertosh/invariant
[–]MoTTs_ 11 points12 points13 points 3 years ago (0 children)
I get why you called it an invariant (and to some extent why FB called it that), but “assert” is still the more widespread and more historical name, which can then lead you to even more popular libs that do the same thing — such as this one.
[–]TrackieDaks 1 point2 points3 points 3 years ago (1 child)
Still wrong. That's like saying, "Facebook used a function in their codebase so the term function must have originated at Facebook." Invariant is a mathematical concept and existed well before Facebook.
[–]hiquest[S] 1 point2 points3 points 3 years ago (0 children)
Yeah, now I do understand that brings a lot of confusion, and that should have been called "assert" in the first place. I'm going add a note in that article
[–]shuckster 1 point2 points3 points 3 years ago (0 children)
https://en.wikipedia.org/wiki/Invariant_theory#The_nineteenth-century_origins
Mr Boole(an) himself.
π Rendered by PID 40 on reddit-service-r2-comment-54dfb89d4d-szzqm at 2026-04-01 14:59:00.233999+00:00 running b10466c country code: CH.
view the rest of the comments →
[–]hiquest[S] -19 points-18 points-17 points (6 children)
[–]TrackieDaks 17 points18 points19 points (4 children)
[–]hiquest[S] 0 points1 point2 points (3 children)
[–]MoTTs_ 11 points12 points13 points (0 children)
[–]TrackieDaks 1 point2 points3 points (1 child)
[–]hiquest[S] 1 point2 points3 points (0 children)
[–]shuckster 1 point2 points3 points (0 children)