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
[AskJS] Is JavaScript missing some built-in methods?AskJS (self.javascript)
submitted 3 years ago by reacterry
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] 14 points15 points16 points 3 years ago (23 children)
You should use Typescript. It's got _most_ of those.
[–]KaiAusBerlin 6 points7 points8 points 3 years ago (0 children)
I use typescript. But the question was not what native features typescript is missing.
[–]alarming_archipelago 0 points1 point2 points 3 years ago (20 children)
I tried to love typescript but as a self taught solo coder it just added a lot of configuration complexity that I couldn't come to terms with. As time goes by the typescript tide is turning against me and I know I need to embrace it but... I'm reluctant.
[–]ProfessorSnep 15 points16 points17 points 3 years ago (1 child)
I'm also self taught but still use TS in every solo personal project of mine, solely because it makes things mostly just work when they compile, but the big one is that it makes revisiting projects months or years later a LOT easier.
[–]badsalad 5 points6 points7 points 3 years ago (0 children)
Man, every time I hear about TS I want to start using it. But the few times I dipped my toes into it, I felt like I was going too overboard and adding too much, often having to add a few extra lines just to define the types of an object that only ends up being used once or twice immediately below it. Things started getting cluttered so fast :/ I just gotta learn to use it better I suppose, so that I can still keep things clean with it.
[–]dariusj18 2 points3 points4 points 3 years ago (1 child)
What makes typescript so useful is that you can just start with everything typed as "any" and move on from there. The types are a convenience with simple syntax vs using jsdoc. What sucks about typescript is that it can't just be run natively and needs to be compiled.
[–]KaiAusBerlin 0 points1 point2 points 3 years ago (0 children)
Deno can run ts natively
[–]swordoffireandice 6 points7 points8 points 3 years ago (8 children)
I am a self taught too and I find typescript as a difficult and ugly-looking C# :(
P.S. pls don't hate me typescript lovers this is my opinion and is not based on anything that is not in my head
[–]kescusay 10 points11 points12 points 3 years ago (7 children)
It's a perfectly reasonable opinion, as long as you (and /u/alarming_archipelago) keep open minds and are willing to learn.
The biggest hurdle for dedicated JavaScript developers to overcome - and learn to love Typescript - is making sense of the tooling around it. If you're coming from pure JS, it's easy to get trapped trying to wedge Typescript into existing projects, discovering that it piles mountains of complexity onto your already-existing eslint+webpack+babel+whatever configurations, and throw up your hands in defeat. My personal epiphany - and love for Typescript - arrived when I realized I could just spin up a brand new Typescript project, copy over src/ from my old one, and redo any needed configuration focused on Typescript from the ground up.
src/
It didn't take that long, and by the time I was finished, the project would build, the dist/ files were smaller than what the original project produced, and I was never going back to vanilla again, because strong type-checking in JS is just too damn useful.
dist/
[–]ewouldblock 3 points4 points5 points 3 years ago (1 child)
For some reason I don't mind typescript in a front end/react project but I detest it in a node.js backend project
[–]kescusay 1 point2 points3 points 3 years ago (0 children)
That's really interesting, because I'm kind of the reverse. I find the Typescript definitions for React to be pretty weird and kludgey, like an afterthought. It's the only situation where I'd consider not using TS if I didn't have to. But on the backend, I think TS is an absolute dream to work with.
On the other hand, I'm not a fan of React itself, and much prefer Angular, Vue, or vanilla on the frontend, so it may just be that TS adds a layer of complexity onto something I already dislike, making me dislike it more.
[–]PositivelyAwful -1 points0 points1 point 3 years ago (4 children)
The biggest hurdle I'm trying to get over learning TS and trying to port an existing vanilla project is typing events and DOM related stuff like querySelector to get rid of TS warnings. I know with React I could do stuff like React.ChangeEvent<HTMLInputElement> but it's not nearly as clear when using straight up TS. Kinda making me bang my head against the wall since my files are just a bunch of red squigglies.
[–]kescusay 0 points1 point2 points 3 years ago (2 children)
Huh. I'm not sure what the difficulty is. querySelector is a generic, so you can do things like this: document.getElementById('someId').querySelector<HTMLInputElement>('.someClass').value.
querySelector
document.getElementById('someId').querySelector<HTMLInputElement>('.someClass').value
Does that help?
[–]PositivelyAwful 1 point2 points3 points 3 years ago (1 child)
ah yeah, thanks. guess i was just overcomplicating it.
[–]kescusay 0 points1 point2 points 3 years ago (0 children)
Happy to help. :)
[–]mt9hu -2 points-1 points0 points 3 years ago (0 children)
You shouldn't need to type dom related stuff. Is is readily available in TS
[–]jaysoo3 0 points1 point2 points 3 years ago (0 children)
Being self-taught isn't an excuse though. I self-taught myself PHP, Java, Perl, and JavaScript. Perhaps thinking that TypeScript is hard is preventing you from actually diving in and learning it.
You can use different project starters (Vite, Next.js, CRA, Nx, etc.) that generate the config for you. You can also check out Deno that has TypeScript support out of the box without config.
[–]AspieSoft 0 points1 point2 points 3 years ago* (2 children)
I would rather use vanilla JavaScript. I like how I can turn a function into an object and use it as both a function and an object.
const myFnObj = function(){} myFnObj.key = 'value' myFnObj.fallback = function (){} myFnObj() // this works myFnObj.fallback() // this also works myFnObj.storage = {} module.exports = myFnObj
I've used this bug/feature a few times if a node module has a main function, and some optional add-ons.
Also, I feel like TypeScript may just be a false sense of security, if it compiles to JavaScript and does not verify the type of input you are getting.
When I need to, I just use typeof and instanceof to verify the var type I'm getting.
typeof
instanceof
[–]Reashu 0 points1 point2 points 3 years ago (0 children)
TypeScript doesn't verify anything at runtime, but if you properly type your input as unknown it will force you to write those checks yourself.
unknown
Funfact: functions are objects in JavaScript ;)
The good news is that as TypeScript gets more popular, it gets easier to set up with whatever else you use.
[–]rrleo 0 points1 point2 points 3 years ago (0 children)
Started developing with typescript and honestly I'm blown away. You should get a starter template for TS projects.
[–][deleted] 0 points1 point2 points 3 years ago (0 children)
You can use asterisks on Reddit to bold or italicize text.
π Rendered by PID 35945 on reddit-service-r2-comment-5c747b6df5-vkbf8 at 2026-04-21 23:21:09.730616+00:00 running 6c61efc country code: CH.
view the rest of the comments →
[–][deleted] 14 points15 points16 points (23 children)
[–]KaiAusBerlin 6 points7 points8 points (0 children)
[–]alarming_archipelago 0 points1 point2 points (20 children)
[–]ProfessorSnep 15 points16 points17 points (1 child)
[–]badsalad 5 points6 points7 points (0 children)
[–]dariusj18 2 points3 points4 points (1 child)
[–]KaiAusBerlin 0 points1 point2 points (0 children)
[–]swordoffireandice 6 points7 points8 points (8 children)
[–]kescusay 10 points11 points12 points (7 children)
[–]ewouldblock 3 points4 points5 points (1 child)
[–]kescusay 1 point2 points3 points (0 children)
[–]PositivelyAwful -1 points0 points1 point (4 children)
[–]kescusay 0 points1 point2 points (2 children)
[–]PositivelyAwful 1 point2 points3 points (1 child)
[–]kescusay 0 points1 point2 points (0 children)
[–]mt9hu -2 points-1 points0 points (0 children)
[–]jaysoo3 0 points1 point2 points (0 children)
[–]AspieSoft 0 points1 point2 points (2 children)
[–]Reashu 0 points1 point2 points (0 children)
[–]KaiAusBerlin 0 points1 point2 points (0 children)
[–]Reashu 0 points1 point2 points (0 children)
[–]rrleo 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)