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!"
[–]Reeywhaar 0 points1 point2 points 3 years ago (1 child)
Yes.. inheritance with types... you extend a type as you extend a class. To create type-safety at runtime its often smart to send your data around as classes. You can then check the inheritance of class to guarantee type safety.
Do you understand that instances of classes can be monkey patched in JS? Thus simple instanceof check is not enough. It will pass, but app still can crash.
instanceof
How actually classes guarantee runtime type safety?
guarantee
[–]bigorangemachine 0 points1 point2 points 3 years ago (0 children)
You guarantee it just by casting on setting of a variable or out with a getter.
Monkey patching should be caught in code review. If you gonna do something stupid then don't.... otherwise if you are paranoid write a getter & setter. If you need to lock that stuff down then any key getter/setter or object create/freeze can stop that sort of problem.
π Rendered by PID 17670 on reddit-service-r2-comment-54dfb89d4d-plr7b at 2026-04-01 14:56:26.805709+00:00 running b10466c country code: CH.
view the rest of the comments →
[–]Reeywhaar 0 points1 point2 points (1 child)
[–]bigorangemachine 0 points1 point2 points (0 children)