🚀 Day 4 – Truthy & Falsy Values in JavaScript Not everything in JavaScript is strictly true or false… and that’s where many subtle bugs begin. Understanding truthy and falsy values helps you write cleaner, more predictable code—especially when working with conditions in real-world apps (hello Angular devs 👋). 🔍 Key Takeaways: ✔ JavaScript has only a few falsy values: false, 0, "", null, undefined, NaN ✔ Everything else is truthy ✔ Cleaner conditions = better readability ✔ But be careful! 0 and "" can trick you #JavaScript #Angular #WebDevelopment #Frontend #CodingTips #LearnToCode
Truthy & Falsy Values in JavaScript: Understanding JavaScript's Conditional Logic
More Relevant Posts
-
💻 Day 27 of 30 Days of JavaScript Clean code isn’t about being fancy — it’s about being understandable. Here’s what changed my code quality 👇 ✔️ Meaningful variable names ✔️ Small, focused functions ✔️ DRY principle ✔️ Less comments, more clarity ✔️ Proper error handling ✔️ Lean Angular components 👉 Write code like someone else will maintain it… …because that someone is probably you in 3 months 😅 #javascript #angular #cleancode #webdevelopment #frontend #softwareengineering
To view or add a comment, sign in
-
-
✨ Master JavaScript Array Destructuring for Cleaner Code Modern JavaScript lets you extract values in one line—making your code shorter, clearer, and easier to maintain. 🧠 Why it matters: Readable code = fewer bugs + faster development. ⚛️ If you’re using React, you’re already using destructuring (useState, useReducer). #JavaScript #FrontendDevelopment #WebDevelopment #ReactJS #CleanCode #ModernJS #SoftwareEngineering
To view or add a comment, sign in
-
-
Hey JavaScript devs 👋 Did you know `this` can silently disappear in 3 very common situations? 1. Detaching a method from its object const fn = obj.greet; fn(); // this → undefined 💀 2. Passing a method as a callback setTimeout(obj.greet, 0); // this → gone [1,2,3].forEach(obj.process); // same story 3. Arrow function in an object literal const obj = { name: 'Pavel', greet: () => console.log(this.name) // this → global, not obj }; The fix is always one of three things: `.bind()`, a wrapper arrow function, or class field arrow methods. Which one bit you the hardest? Drop it in the comments 👇 #JavaScript #WebDev #Frontend #JS
To view or add a comment, sign in
-
-
Unpopular opinion: you don't need to learn every JavaScript framework. I spent months anxious that I wasn't learning fast enough. React came out with something new. A new framework dropped. Everyone was talking about it. Here's what I wish someone told me earlier: > Pick one thing. Get genuinely good at it. Then expand. > I focused on React and CSS fundamentals for my first year. That decision paid off more than chasing every trend. > The frontend ecosystem moves fast. That's exciting — but it's also a trap if you're not careful. What's the one thing you wish you'd focused on earlier? #JavaScript #React #Frontend #WebDevelopment #LessonsLearned
To view or add a comment, sign in
-
Day 25 of 30 Days of JavaScript 🚀 Fetch vs HttpClient — same goal, different power 💪 If you're working with Angular, switching from Fetch to HttpClient is a game changer: ✔ Cleaner code ✔ Better error handling ✔ Powerful interceptors ✔ RxJS magic ✨ 👉 Fetch is great for simple JS 👉 HttpClient is built for real-world Angular apps Which one do you use more? 👇 #JavaScript #Angular #WebDevelopment #Frontend #100DaysOfCode #RxJS #Developers #CodingTips
To view or add a comment, sign in
-
-
Many developers keep switching between React, Vue, Angular, and new tools… But without strong fundamentals, everything feels confusing. Focus on: • JavaScript core concepts • DOM & browser behavior • Logic & problem solving • CSS fundamentals Once your basics are strong, you can learn any framework easily. 💡 Don’t chase tools — master the foundation. What do you focus on more? 👇 Fundamentals or frameworks? #WebDevelopment #JavaScript #ProgrammingBasics #FrontendDeveloper #DeveloperTips #CodingJourney #LearnToCode #BuildInPublic
To view or add a comment, sign in
-
-
💡 #JavaScript Global vs Local Variables (Simple Explanation) If you're learning JavaScript, understanding variable scope is a must 👇 🔹 Global Variables Declared outside any function Accessible from anywhere in your code Can be used across multiple functions Example: var name = "Avi"; function greet() { console.log(name); // Accessible here } 🔹 Local Variables Declared inside a function or block Accessible only within that function/block Helps avoid unwanted changes from outside Example: function greet() { var message = "Hello"; console.log(message); // Works here } console.log(message); // ❌ Error ⚡ Key Difference Global = accessible everywhere Local = accessible only inside its scope 👉 Tip: Prefer #local variables to keep your code clean and avoid bugs. Use #global where multiple parts of your app need the same value. #frontend #js #javascript
To view or add a comment, sign in
-
-
most developers don't know the difference between null , undefined and "" and it's breaking their React forms silently. - always initialise string state with ' ' not undefined - always initialise array state with [ ] not undefined - always initialise object state with { } not undefined here's why it matters beyond the warning: - undefined means "this was never set" - null means "this was intentionally set to nothing" - ' ' means "this exists but is currently empty" React treats these three things completely differently when rendering. your form works locally because you fill it in immediately. it breaks in production because someone submits without touching a field. initialise your state properly. #reactjs #typescript #webdevelopment #buildinpublic #javascript
To view or add a comment, sign in
-
-
Can you cancel a Promise in JavaScript? Short answer: No — but you can cancel the work behind it. A Promise is just a result container, not the async operation itself. Once created, it will resolve or reject — you can’t “stop” it directly. What you can do instead: • Use AbortController → cancels APIs like fetch • Use cancellation flags/tokens → for custom async logic • Clear timers → if work is scheduled (setTimeout) • Ignore results → soft cancel pattern Real-world takeaway: Design your async code to be cancel-aware, not Promise-dependent. This is exactly how modern tools like React Query handle requests under the hood. #JavaScript #Frontend #AsyncProgramming #WebDevelopment #ReactJS #CleanCode
To view or add a comment, sign in
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