7 JavaScript Features I Wish I Knew Sooner
Because reinventing the wheel at 1 AM with spaghetti code is overrated.
Let me guessâŚ
Youâve stared at your screen, drowning in nested callbacks, wondering if thereâs a better way.
Youâve screamed internally (or audibly) trying to center a div and debug a mystery undefined.
Youâve googled âhow to clone an object in JavaScriptâ more times than youâve opened StackOverflow.
Yeah. Same here.
When I started my JavaScript journey, I thought I had to manually build everything â loops, conditions, the works â like I was coding in 1999.
No one told me JS had evolved. No one said, âHey, these built-in features exist, and theyâll save your butt.â So here I am, telling you.
Grab a coffee, or a Red Bull, and let me spare you from my pain.
Here are 7 JavaScript features I wish I knew before I tried to write my own deep clone function.
Press enter or click to view image in full size
Img edt:- Mark
1. Optional Chaining (?.)
If youâve ever written,
if (user && user.profile && user.profile.email)
congratulations, youâre doing too much.
Instead, do this:
const email = user?.profile?.email;
Boom. No error, no tears.
Itâs like JavaScript finally grew up and stopped throwing tantrums when things are undefined.
2. Nullish Coalescing (??)
You think || is your friend? Nope. Itâs a backstabbing liar when 0, false, or "" enter the chat.
const count = userInput ?? 10;
This only falls back to 10 if userInput is null or undefined.
Unlike ||, it respects falsy values like 0. Because maybe your user did enter 0 on purpose. Donât be rude.
3. Destructuring
I used to write:
const name = user.name;
const age = user.age;
Like a Neanderthal.
Now?
const { name, age } = user;
Modern problems require modern solutions.
Bonus points for destructuring in function parameters:
function greet({ name }) {
console.log(Hello, ${name});
}
Yes. Itâs that clean.
4. Spread and Rest Operators (...)
Three dots. Infinite power.
const newArray = [âŚoldArray, 4];
const newObj = { âŚoldObj, updated: true };
And in functions:
function sum(âŚnumbers) {
return numbers.reduce((a, b) => a + b, 0);
}
Use it. Abuse it. Just donât confuse ...rest and ...spreadâone gathers, one scatters.
5. Array.map() and friends
Forget for loops. Weâre not savages.
const doubled = [1, 2, 3].map(n => n * 2);
Chaining .filter().map().reduce() is the JS version of a flex.
Cleaner, smarter, cooler. Like drinking oat milk lattes with your code editor.
6. Template Literals
Backticks > quotes. Always.
const message = Hello, ${name}. You have ${count} new messages.;
No more messy + signs or broken strings. Itâs 2025. We template now.
7. Set and Map
When youâve had enough of using objects as poor-manâs hashmaps:
const ids = new Set([1, 2, 2, 3]);
console.log(ids); // 1, 2, 3
Want key-value pairs that donât mess with __proto__? Use Map :
const map = new Map();
map.set(âkeyâ, âvalueâ);
Trust me.
These data structures donât get enough love, but theyâll change how you write logic forever.
Finally, Donât Learn the Hard Way (Like I Did)
I spent years reinventing wheels I didnât know already existed. JavaScript is messy, yes. But it also has a ton of elegant features that â when you know about them â make it feel like a whole new language.
So do yourself a favor: bookmark this, share it with your dev friends, and stop suffering in silence.
Letâs talk.
Which of these did you also discover way too late? Got a feature I missed? Drop it in the comments.
Or scream about it on Twitter. Just donât gatekeep good JavaScript.
