Hot take 🔥 If your ternary operator needs a second line, it needs an if/else statement instead. Readability > Brevity All thanks to Scrimba #WebDev #JavaScript
JavaScript Ternary Operator Best Practices
More Relevant Posts
-
Understanding async is a turning point in JavaScript. Just published a beginner-friendly blog on Synchronous vs Asynchronous JS ✨ 👉 https://lnkd.in/g-RB5ZU2 Chai Aur Code Hitesh Choudhary Piyush Garg Akash Kadlag Anirudh Jwala #chaicode #javascript
To view or add a comment, sign in
-
-
Day 10 of 100 🎉 — Double digits!! In JavaScript, there is ONE value that is NOT equal to itself. Not a bug. Not a mistake. It's by design. 😱 Comment down 👇 5 lines — 5 answers! Hint: Its name literally says "Not a Number" — yet typeof says it IS a number. And isNaN vs Number.isNaN behave differently too. This one has LAYERS! 🧅 Full explanation in the comments tonight! #100DaysOfCode #JavaScript #CodingInterview #JavaScriptTips #WebDevelopment
To view or add a comment, sign in
-
-
🧠 What is Anagram? 👉 Two strings are anagrams if: ✔ Same characters ✔ Same frequency ✔ Different order 📌 Example: listen → silent ✅ evil → vile ✅ ❌ Not Anagram: hello → world 💻 Code: const isAnagram = (a, b) => a.split("").sort().join("") === b.split("").sort().join(""); 💡 Trick: Sort & Compare #DSA #JavaScript #ProblemSolving
To view or add a comment, sign in
-
🚫 Stop writing ugly numbers in JavaScript. There's a better way. Instead of squinting at 1000000, you can write 1_000_000 — same value, way more readable. const price = 1_000_000; // same as 1000000 const users = 10_000; // same as 10000 const interval = 4_500; // 4.5 seconds No performance cost. No runtime difference. Just cleaner code. The underscore is just a visual separator — JavaScript ignores it completely. Yet somehow it makes your code feel 10× more professional. Small trick. Big difference. 🚀 #JavaScript #TypeScript #CleanCode #WebDev
To view or add a comment, sign in
-
-
We analyzed a page with 22MB uncompressed size. 17MB of that? JavaScript. 140 JS requests. 19.1s JS execution time. 4.6s TBT 🧐 Too much JavaScript hurts performance and your visitors feel it. Learn how you can fix it: https://lnkd.in/eER3Y65P #webperformance #gtmetrix
To view or add a comment, sign in
-
-
🌐 Read the blog - Click here to explore: https://lnkd.in/gGnquH-r 🚀 Just published a new blog on Error Handling in JavaScript: Try, Catch, Finally. In this article, I explain how to handle errors in JavaScript using try, catch, and finally blocks. I covered how errors occur, how to catch them safely, and how finally ensures code runs no matter what. A beginner-friendly guide to writing more robust and error-free JavaScript code. Inspired by the amazing teaching of Hitesh Choudhary Sir and Piyush Garg Sir from Chai Aur Code. ☕💻 #javascript #webdevelopment #learninginpublic #chaiAurCode
To view or add a comment, sign in
-
-
Ever wondered why changing employee1 also changes employee in JavaScript? 🤯 It’s the classic Reference Trap—objects are stored in the heap, and the = operator only copies the reference, not the object itself. In my latest video, I break down how memory references work and why mastering Pass by Reference is key to writing bug-free code. 👉 Watch the full explanation and level up your JavaScript skills! 🎬 #JavaScript #CodingTips #WebDevelopment #ProgrammingConcepts
To view or add a comment, sign in
-
How to understand a Javascript function? What arguments are passed? Why it is passed? What is the function doing inside? What it is returning? What does the JS doing with the returned value? If you can answer to all the questions then you have understood a function. #Javascript #frontenddevelopement
To view or add a comment, sign in
-
𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗖𝗹𝗮𝘀𝘀𝗲𝘀? 𝗡𝗼𝘁 𝗥𝗲𝗮𝗹𝗹𝘆 🧠 JS doesn’t have real classes, it’s all prototypes, and classes are just syntactic sugar. Today’s session made this click, prototypes, constructor functions, and how modern class syntax actually works under the hood. #JavaScript #ChaiCode #WebDev
To view or add a comment, sign in
-
-
💡 JavaScript Practice — Counting Vowels A small problem, but a good test of logic: 👉 Count the number of vowels in a string Here’s my solution: const str = "javascript"; const vowels = "aeiouAEIOU"; let count = 0; for (let letter of str) { for (let vowel of vowels) { if (letter === vowel) count++; } } console.log(count); 🧠 What this taught me: • How nested loops actually work in real scenarios • Breaking a problem into smaller steps • Writing simple, readable logic ⚡ Next step: I’ll try optimizing this (maybe using includes() or a better approach) If you have a cleaner or more efficient solution, I’d love to see it. #JavaScript #ProblemSolving #WebDevelopment #LearningInPublic
To view or add a comment, sign in
More from this author
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development
In flutter widget trees, or JavaScript strings like `…${…} …`, these are basically evaluated arguments: ternary operators are better, or else, I might end up with Text( (){if foo return bar; return baz;}() )