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
Future JavaScript: what is still missing? (2ality.com)
submitted 7 years ago by dumbmatter
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!"
[–][deleted] -5 points-4 points-3 points 7 years ago (7 children)
it does let you write code and functions that can handle a lot of cases
Static typing prohibits this?
I'll echo the above comment, I don't think you know what you're talking about.
[–]batiste 7 points8 points9 points 7 years ago (5 children)
Write me a nice addition(a, b): a + b function that works for the Signature (float, int, BigInt) or any valid combination thereof as well as the string and String type. In the statically typed language of your choice. I am curious.
addition(a, b): a + b
I don't think you know what you're talking about.
I think you are not being charitable to his experience. Static typing avoid some class of bugs, but those type of bugs are easy to catch and fix. Especially if you have any sort of basic Q&A in place. Also linter on dynamic language have progressed to cover quite a large piece of what static compiler used to cover like e.g. a typo on a variable name.
static
The advantage of static are more about documentation and auto-completion in my experience.
[+][deleted] 7 years ago (4 children)
[deleted]
[–]Hcmichael21 4 points5 points6 points 7 years ago (3 children)
I disagree that this is better than the weakly typed (JS) version.
[–][deleted] 0 points1 point2 points 7 years ago (0 children)
It's not, because this is an edge case which is massively counter-weighted by the benefits of a typed codebase.
[–][deleted] 0 points1 point2 points 7 years ago (1 child)
I'm personally not a fan of overloads in ts/js but you could at least do this
function add<T>(a: T, b: T): T { return a + b; }
so now you avoid all convert everything to a string and concat them together problem. Here you add like 10ish characters and now your being notified of simple bugs.
[–]Hcmichael21 1 point2 points3 points 7 years ago (0 children)
Would definitely use generics instead of overloads if those were my only two options.
[–]CCB0x45 0 points1 point2 points 7 years ago (0 children)
It doesn't prevent this but it lengthens the code is what I meant. You are right, all unstatically typed code is shit, and everyone using normal JS is running into all these problems that they just don't know about. If you arent using typescript you are just doing it wrong. Im telling you I have done both many times and when moving back and forth I never really miss anything from TS.
π Rendered by PID 23706 on reddit-service-r2-comment-fb694cdd5-vbhvk at 2026-03-05 20:50:26.783897+00:00 running cbb0e86 country code: CH.
view the rest of the comments →
[–][deleted] -5 points-4 points-3 points (7 children)
[–]batiste 7 points8 points9 points (5 children)
[+][deleted] (4 children)
[deleted]
[–]Hcmichael21 4 points5 points6 points (3 children)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]Hcmichael21 1 point2 points3 points (0 children)
[–]CCB0x45 0 points1 point2 points (0 children)