14
Elyz
5y

I just learned Javascript doesn't have tuples and nearly cried and/or vomited all over my keyboard. Pls no.

Comments
  • 2
    Use TS?
  • 1
    @asgs does TS have tuples? That's good to know, I'll have to strongly suggest that next time. Unfortunately I don't get to pick my preference this time around.
  • 2
    @irene a terrible one. A true dad joke.
  • 6
    @Elyz
    Since JS is dynamically typed, couldn't you just use an array?
  • 4
    @metamourge I can and I had to, but it's so ugly my eyeballs are burning.
  • 9
    everything are arrays, just because you don't have couple babysitting alias' doesn't mean the function is gone

    https://github.com/Olical/tuple

    https://medium.com/better-programmi...

    https://medium.com/@ntgard/...
  • 4
    @JoshBent obviously. That doesn't change that sometimes syntactic sugar is nicer to work with. Personally I enjoy strings over char arrays too..
  • 4
    @Elyz a lot of things ES6 introduced many other languages lack, that meme of "ughhh javascript guys LOOOOOL, am I right?" is more discrediting than funny most of the time in my opinion, same with php7+ in above quote.

    I agree "sugar" is great, but if you need it out of habit and it is missing, you can implement it via module, extension or just use things like lodash. TS is also just a wrapper for JS.
  • 1
    @Ubbe I wouldn't personally have picked JS for what I am trying to do but alas. One doesn't always get a choice. I'd have implemented it in a functional language if I had free reins.
  • 0
    @Ubbe oh yeah for sure. JS is not my preferred language but I see it has its uses. I'll just leave that to the people who understand how to use it better 🤭
  • 2
    I think the most offensive thing left out of JS is actually enums. You can do

    const MyEnum = {
    a: 1,
    b: 2
    };

    But if you need to personally type the numbers what's the point?

    @JoshBent
  • 0
    @AlgoRythm you forgot to freeze that object, otherwise it isn't an enum, also if you have more enum types than you're able/want to write values/numbers for, you need to refactor, handy trick isn't it? :)
Add Comment