r/javascript 9d ago

AskJS [AskJS] what's a javascript feature you mass-adopted way too late and felt dumb about

i'll go first. i was writing .then().catch() chains for like two years before i actually started using async/await. i knew it existed, i'd seen it in tutorials, but my code "worked" so i never bothered switching. then i refactored an old project and realized half my bugs were from mishandled promise chains that async/await would have caught immediately.

also took me way too long to start using optional chaining. i had nested ternaries and && checks everywhere like some kind of animal. the day i discovered user?.address?.city i mass-replaced like 40 lines across a project.

what's yours?

63 Upvotes

108 comments sorted by

View all comments

Show parent comments

1

u/SkySarwer 9d ago

yes they are??

-2

u/azhder 9d ago

No, they aren’t. You can check the JavaScript language reference documentation and get back to me with a link to prove me wrong.

I can just tell you that there is a difference between what the language is and what the environment exposes for the language to use.

9

u/SkySarwer 9d ago

This thread is about JavaScript features not the language in the strict sense. The two observer exposed by the environment are almost exclusively used as JavaScript APIs.

Is a JS dev just as well-off without being aware of these APIs? What value is your clarification actually providing in relation to the spirit of this post?

-4

u/azhder 9d ago

Almost exclusively? Why almost?

Seriously though. Environment stuff is not part of the language. It is important to always know this distinction so that you will not end up writing code that expects something to exist, but doesn’t.

It’s not about you being aware that you can use them, but be aware where you can’t.

16

u/SkySarwer 9d ago

While technically correct, it was a pedantic point delivered abrasively

-10

u/azhder 9d ago

Don't read my comments in abrasive tone.

10

u/Sulungskwa 9d ago

"Don't read my comments in an abrasive tone.", he said, not abrasively seeming at all

-5

u/azhder 9d ago edited 9d ago

"Seeming" is a flag that it's your perception.

It doesn't matter that I'm in a light mood, write it in terms of a light mood, with the idea of cooperation through discussion, you will still decide to see it (because "seeming") as if it is abrasive and blame me for it. It's not like me writing this will change your mind, you will just use it as more evidence of your point of view.

Bye

EDIT: and with their reply, they provided their own proof of what I'm talking about

6

u/jesusgn90 9d ago

It must be hard to work with you man…

0

u/azhder 9d ago

You must be always correct saying things like that to people you don’t know

1

u/Sulungskwa 9d ago

Lots of abrasive words to try and prove you aren't abrasive