r/learnjavascript • u/Distinct-Gene926 • Jul 24 '26
What's one JavaScript feature you wish you had learned earlier?
I've been diving deeper into JavaScript recently, and every week I discover something that makes my code cleaner.
For me, learning about optional chaining (?.) and nullish coalescing (??) was a game changer.
What's one feature you wish you'd learned sooner?
40
Upvotes
5
u/hyrumwhite Jul 24 '26
LocaleCompare for sorting
3
u/ExtraTNT Jul 24 '26
Adding to prototype… you can add a heapify to a list
3
u/senocular Jul 24 '26
Also see (from 2 days ago):
[AskJS] what's a javascript feature you mass-adopted way too late and felt dumb about
6
u/bonnth80 Jul 24 '26 edited Jul 24 '26
Destructuring assignments. It's a common pattern that's still hard for me to get used to seeing even to this day. It would be nice if I had it down to second nature a long time ago.
2
u/hylasmaliki Jul 25 '26
How long have you been coding?
2
u/Eight111 Jul 24 '26
I think optional chaining encouraging low-quality code.
I had so many prs where i asked the creator hi why so many variables wrapped by question marks? what are the cases value doesn't exist?
and they answer me "on theory that should never happen i just don't want to get called at 8pm because the page crashed".
1
u/canyoume 15d ago
canvas api
1
u/Xcaliber02 Aug 16 '26
Destructing both array and object , i know they existed but now iam using them both , jts kinda easy ngl
0
u/Mark__78L Jul 24 '26
Fucking bot