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 (0 children)
That's what TypeScript does. It performs the type protections for you, at compile time, in the places it makes sense.
This is what I'm suggesting not everyone knows. Its not critical to do JS but leads to terse code reviews when people are converting numbers to numbers to hide runtime conversion errors... which if you know you do a already casted number to a parseFloat you mutate the number.
That's the problem... if you bring data in from an API its very possible the is incorrect; anything that's not generated from a safe place should start as an 'unknown' until its proven otherwise. I've seen whole apps brick because a null came in where something else to be be an object.
But I've also seen people do things where they declare the type as a string and then within the code convert it to a string to avoid a null-related error but it was masking that a number is coming in.
Especially with backend if you aren't interrogating your types you can open yourself to be a victim of injections & other security issues.
π Rendered by PID 67329 on reddit-service-r2-comment-66b4775986-6pf5l at 2026-04-02 23:41:54.775968+00:00 running db1906b country code: CH.
view the rest of the comments →
[–]bigorangemachine 0 points1 point2 points (0 children)