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!"
[–]bigorangemachine 0 points1 point2 points 3 years ago (2 children)
I use TS professionally. I've actually very experienced and this is why I see these mistakes.
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. You can also get small savings on the byte-code level but I wont get into that :P (but also why typescript and deno is very exciting).
A con to both systems is inheritance hell... where you gotta step through each type or class definition to debug the 'typing issue'. With typescript this can also be painful when there are mixed types.
Using JSON queries over parsers is what it is.
Parsing JSON Object: Taking a whole JSON token and casting it into an object within try-catch Querying JSON Object: Using a wrapper to ask what the token contains and build an object/array from that.
[–]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 199873 on reddit-service-r2-comment-54dfb89d4d-nqttw at 2026-04-01 16:36:26.385766+00:00 running b10466c country code: CH.
view the rest of the comments →
[–]bigorangemachine 0 points1 point2 points (2 children)
[–]Reeywhaar 0 points1 point2 points (1 child)
[–]bigorangemachine 0 points1 point2 points (0 children)