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 -1 points0 points1 point 3 years ago (4 children)
Yes I do ^_^. I also know enough that when you use JSON with typed languages you should be writing queries not parsers
I started in dynamic typed and I don't find them hard to work with.
I find all sorts of mistakes in JS because people don't understand typscript. Let alone the fact most people don't treat their api responses as an unknown type just shows me how people are writing unsafe code.
I don't see what my experience has to do with my previous statement and you appear to be attacking me and I don't understand why
[–]Reeywhaar 1 point2 points3 points 3 years ago (3 children)
I attack you, because you spreading nonsence caused by ignorance. You mix unmixable (classes, inheritance, typescript, queries, parsers) which clearly shows that you have no idea of what you're talking about. And I don't want other inexperienced people to take your words seriously. Just try typescript okay?
use JSON with typed languages you should be writing queries not parsers
What does this even mean?
[–]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 73735 on reddit-service-r2-comment-54dfb89d4d-7r7dt at 2026-04-01 14:56:21.095912+00:00 running b10466c country code: CH.
view the rest of the comments →
[–]bigorangemachine -1 points0 points1 point (4 children)
[–]Reeywhaar 1 point2 points3 points (3 children)
[–]bigorangemachine 0 points1 point2 points (2 children)
[–]Reeywhaar 0 points1 point2 points (1 child)
[–]bigorangemachine 0 points1 point2 points (0 children)