Day 4 of #100DaysOfCode: Array Logic & The Magic of Truthy/Falsy in JS ⚡ Today was about mastering the fundamentals that make JavaScript unique. I split my time between solving algorithmic problems and digging deep into JS engine mechanics. 1️⃣ Data Structures & Algorithms: I tackled the "Concatenation of Array" problem (LeetCode 1929). The goal was to create an array of length 2n by concatenating two nums arrays. Key takeaway: It’s a great exercise in understanding array indexing and memory allocation. It’s simple on the surface, but efficient array manipulation is core to everything. 2️⃣ Web Development Concepts: I dove into Truthy & Falsy values. Coming from other languages, JS handling of conditionals is fascinating. I learned that 0, "", null, undefined, and NaN are the only falsy values. Everything else—including empty arrays [] and objects {}—is truthy. #JavaScript #DSA #WebDevelopment #MERNStack #CodingJourney #100DaysOfChallenge
Mastering JavaScript Fundamentals: Array Logic & Truthy/Falsy Values
More Relevant Posts
-
Hii Folks 🙂 Yesterday, while discussing the JavaScript Event Loop with a senior, I realized something important. Most of us explain the Event Loop using queues and the call stack. That explanation is correct, but it’s incomplete. It answers how things run, not why they behave the way they do. The deeper question came up: Before the Event Loop even starts scheduling tasks, how does JavaScript know what those tasks are allowed to access? That’s where concepts like the compiler and lexical scope quietly enter the picture. JavaScript first reads the code and builds an understanding of it. Variable scope, function boundaries, and memory references are decided before execution begins. This is not the Event Loop’s responsibility. The Event Loop only works with what already exists. Lexical scope determines which variables belong to which functions. Closures decide what stays in memory even after a function finishes. None of this is created by the Event Loop, but all of it affects how async code behaves later. Data structures play a similar hidden role. The call stack is just a stack. Task queues are just queues. The scope chain behaves like a linked structure. The Event Loop doesn’t interpret logic. It simply moves execution between these structures based on a few strict rules. That discussion made one thing clear to me: If we don’t understand compiler behavior, lexical scoping, and basic data structures, the Event Loop will always feel confusing or “magical”. Async issues are rarely caused by the Event Loop itself. They usually come from misunderstanding scope, memory, or execution order. Once you see the Event Loop as a coordinator rather than a decision-maker, a lot of confusion disappears. #JavaScript #EventLoop #LexicalScope #Closures #AsyncProgramming #WebDevelopment #FrontendDevelopment #BackendDevelopment #FullStackDeveloper #SoftwareEngineering #ComputerScience #ProgrammingConcepts #DataStructures #DeveloperLearning #LearningInPublic #TechDiscussions #DeveloperCommunity #CodingLife #Debugging #EngineeringMindset #TechCareers
To view or add a comment, sign in
-
-
Why I stopped fearing "Complex" JavaScript. Yesterday’s Sunday session with the #ChaiAurCode cohort was a game-changer. We didn't just look at syntax, we looked at the "Why" behind how JavaScript handles logic. The Power of Higher Order Functions (HOF): I finally understood the "Super-Tool" of JS. Learning how functions can accept other functions as arguments (or return them) opened my eyes. It’s the secret sauce that makes our code modular and clean. The "Big Four" Array Methods: Using our new HOF knowledge, we tackled forEach, map, filter, and the one I used to avoid at all costs: .reduce(). Thanks to Hitesh Choudhary sir’s effortless explanation, reduce is no longer a "confusing math thing" it’s now one of my favorite tools for data manipulation. Key Technical Takeaways: The Argument Reality: A huge "Aha!" moment was seeing that Regular Functions hold an arguments object by default, while Arrow Functions do not. Looping Efficiency: Deep-dived into for...of and for...in to understand which tool to use for which job. Advanced Patterns: Mastered the syntax of IIFE (Immediately Invoked Function Expressions) for data privacy and got a teaser for Closures which we’ll be dissecting next. Huge gratitude to my mentors Hitesh Choudhary and Piyush Garg. The way this cohort bridges the gap between "knowing" and "doing" is exactly what the dev community needs in 2026. Ready to put these HOFs to work! ☕️ #JavaScript #WebDevelopment #ChaiAurCode #HigherOrderFunctions #HiteshChoudhary #PiyushGarg #FrontendDev #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Javascript arrays are more powerful than you think. 🚀 I used to write complex for loops for data manipulation. Then I truly understood the power of array methods. It’s not just about shorter code—it’s about readability and intent. Three underused methods that deserve more love: .some(): Checks if at least one element passes a test. Great for validation. .every(): Checks if all elements pass. Perfect for form checking. .reduce(): The Swiss Army knife. From summing numbers to reshaping entire data structures. Clean code isn't about being clever; it's about making your logic obvious to the next developer who reads it (which is usually you, six months later). Which array method do you find yourself using the most? #JavaScript #Coding #SoftwareEngineering #WebDev #CleanCode
To view or add a comment, sign in
-
Data Structures & String Magic Today was all about how we store and manipulate data in JavaScript. I moved beyond simple variables and explored the power of Strings and Objects. It’s fascinating to see how similar Strings and Arrays can be, yet how unique they are in their behavior! My Learning Milestones Today: String Mastery: Explored slice, join, concat, and the importance of case normalization (toLowerCase/toUpperCase) for comparisons. The "Reverse" Challenge: Learned three different ways to reverse a string—a classic interview favorite! Object Essentials: Introduction to Properties and Values. I practiced multiple ways to "get" and "set" data using dot notation and bracket notation. Advanced Object Ops: Working with nested objects, using Object.keys() and Object.values(), and learning how to safely delete properties. Iteration: Mastering how to loop through objects to pull out the data I need. Objects are truly the backbone of JavaScript, and I'm feeling much more confident in how to structure my code. 🚀 #JavaScript #WebDevelopment #CodingJourney #StringsAndObjects #FrontendDev #TechGrowth
To view or add a comment, sign in
-
-
One thing that keeps surprising me in JavaScript is how often bugs come from mental models, not syntax. A few examples I ran into recently: setTimeout with closures async + looping traps shallow vs deep copies mutation hiding in helper functions Once you slow down and ask: “What does the runtime actually do here?” a lot of things make more sense. Tools change fast. Mental models last longer. Currently strengthening: event loop behavior async flow data structures & immutability Happy to share resources if anyone else is on this path. #JavaScript #WebDevelopment #LearningInPublic #FrontendEngineering #CareerGrowth
To view or add a comment, sign in
-
𝗧𝗵𝗲 𝗙𝘂𝗻𝗰𝘁𝗶𝗼𝗻 𝘁𝗵𝗮𝘁 𝗡𝗲𝘃𝗲𝗿 𝗙𝗼𝗿𝗴𝗲𝘁𝘀: 𝗠𝗮𝘀𝘁𝗲𝗿𝗶𝗻𝗴 𝗖𝗹𝗼𝘀𝘂𝗿𝗲𝘀 🧠 Hi everyone! I’ve just released Part 5 of my JavaScript deep-dive series: 𝗧𝗵𝗲 𝗠𝗲𝗰𝗵𝗮𝗻𝗶𝗰𝘀 𝗼𝗳 𝗖𝗹𝗼𝘀𝘂𝗿𝗲𝘀. Closures are often treated like a "magic trick" in JavaScript interviews, but they are actually a logical result of how the engine links scopes together. If you’ve ever struggled with why a setTimeout in a loop logs the "wrong" number, or how "private" variables actually work in a language without a private keyword, this article is for you. 𝗜𝗻 𝘁𝗵𝗶𝘀 𝗽𝗮𝗿𝘁, 𝗜 𝗱𝗶𝘃𝗲 𝗶𝗻𝘁𝗼: • 𝗧𝗵𝗲 𝗜𝗻𝘁𝗲𝗿𝗻𝗮𝗹 𝗦𝗹𝗼𝘁𝘀: Meet [[Environment]] and [[OuterEnv]], the two hidden connectors that make closures possible. • 𝗩𝗮𝗿𝗶𝗮𝗯𝗹𝗲𝘀 𝘃𝘀. 𝗩𝗮𝗹𝘂𝗲𝘀: Why closures link to "live" variables (and why that leads to the famous loop trap). • 𝗧𝗵𝗲 𝗜𝗜𝗙𝗘 𝘃𝘀. 𝗟𝗲𝘁: How we used to fix closures in the old days vs. the modern ES6 solution. • 𝗘𝗻𝗰𝗮𝗽𝘀𝘂𝗹𝗮𝘁𝗶𝗼𝗻: How to use closures to create "vaults" for your data. Stop guessing how your functions remember data and start understanding the architecture behind it! Read the full article here: https://lnkd.in/dR_TngGA 🔗 𝗡𝗲𝘅𝘁 𝘂𝗽: We tackle the "Grand Design" of JavaScript objects, 𝗣𝗿𝗼𝘁𝗼𝘁𝘆𝗽𝗲𝘀. #JavaScript #SoftwareEngineering #WebDevelopment #Coding #Closures #ProgrammingTips #TechCommunity #ScopeChain
To view or add a comment, sign in
-
✅ Solved LeetCode: Binary Tree Inorder Traversal (94) Implemented a recursive Inorder Traversal in JavaScript, following the sequence: Left → Root → Right. The solution uses a helper function traversal(curr) that: - First explores the left subtree, - Then processes the current node by pushing its value to the result array, - And finally traverses the right subtree. This approach correctly visits nodes in sorted order for a Binary Search Tree (BST) and keeps the logic simple and intuitive using recursion. ⏱ Time Complexity: O(n) — visits every node once 🧠 Space Complexity: O(h) — recursion stack, where h is the height of the tree A must-know problem for mastering tree traversals and recursion in DSA. 🌳
To view or add a comment, sign in
-
-
Mastering the Two Sum Algorithm in JavaScript (O(n) solution) Today I implemented the classic Two Sum problem using an optimized approach with Map in JavaScript. Instead of using the naive O(n²) double loop, I used a hash map to reduce the time complexity to O(n). Here is the core idea: 🔍 Why this approach is powerful Single loop → O(n) time complexity Constant-time lookup using a hash map Clean and scalable logic Interview-ready solution I'm currently strengthening my problem-solving and algorithmic thinking skills daily. You can find the full exercises repository here: 👉 https://lnkd.in/ej4fNeZs Consistency > Motivation. Small improvements every day compound over time. #JavaScript #Algorithms #ProblemSolving #WebDevelopment #100DaysOfCode #SoftwareEngineering
To view or add a comment, sign in
-
-
Is your JS copy a "Duplicate" or just a "Shortcut"? 👯♂️ Updating a "new" object only to see the original change too? That's a Shallow Copy bug. In JavaScript, objects are stored by reference. If you don't copy them correctly, you're just sharing memory. The Quick Fix: 📂 Shallow ({...obj}): Copies the surface. Nested objects stay linked. Use for flat data. 🏗️ Deep (structuredClone): Copies everything. Completely independent. Use for complex data. Stop using JSON.parse hacks. 🛑 I’ve broken down the memory mechanics and real-world "Ghost Mutation" fixes in my latest blog. Read the 2-minute deep dive: 👉 [https://lnkd.in/gzeT3rYw] #JavaScript #CleanCode #WebDev #Programming
To view or add a comment, sign in
-
-
Day 5 | Data Structures & Algorithms with JavaScript Practiced merging two arrays using core JavaScript logic, without relying on built-in methods. This exercise helped me strengthen my understanding of: • Looping and indexing • Array manipulation fundamentals • Writing clean, logical code • Verifying output through browser console Focusing on building strong fundamentals step by step to improve problem-solving skills. 📌 Topic: Merge Two Arrays 📌 Tech: JavaScript #DSA #JavaScript #ProblemSolving #SoftwareDevelopment #FrontendDevelopment #LearningJourney #Consistency #LinkedInLearning
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