🚀 Day 82 of My #100DaysOfCode Challenge Today I learned about a very useful JavaScript feature — Optional Chaining ("?."). When working with deeply nested objects, accessing properties can sometimes cause errors if a value is "undefined" or "null". Optional chaining helps solve this problem by allowing us to safely access nested properties without breaking the code. Example without Optional Chaining const user = { profile: { name: "Tejal" } }; console.log(user.profile.name); If "profile" doesn’t exist, this code would throw an error. Example with Optional Chaining const user = { profile: { name: "Tejal" } }; console.log(user?.profile?.name); Output Tejal If a property doesn't exist, JavaScript simply returns undefined instead of throwing an error. Why this is useful • Prevents runtime errors • Makes code cleaner and shorter • Helpful when working with APIs and complex objects Small modern features like this make JavaScript development much smoother. Continuing to explore deeper concepts and improving step by step. 💻✨ #Day82 #100DaysOfCode #JavaScript #OptionalChaining #WebDevelopment #LearningInPublic
JavaScript Optional Chaining Explained
More Relevant Posts
-
🚀 Day 67 | JavaScript Loops & Array Iteration Today I practiced JavaScript loops and working with arrays of objects 💻 🔹 What I Worked On: • Iterated through array of objects using for loop • Printed all elements and accessed object properties like loc • Used loop with step increment (i += 2) to print alternate values • Practiced reverse counting using for and while loops • Used forEach() for cleaner array iteration 💡 Key Learning: • Arrays of objects are very common in real-world applications • Loop conditions must be handled carefully (i < length vs <= length) • forEach() is simple and readable for iteration • Multiple ways to loop → choose based on requirement 🔥 Takeaway: 👉 Mastering loops is key to handling data efficiently in JavaScript Consistency is improving logic step by step 🚀 #Day67 #JavaScript #Loops #ArrayIteration #ProblemSolving #CodingJourney #10000Coders #WebDevelopment #SravanKumarSir
To view or add a comment, sign in
-
Day 2 of my JavaScript learning journey. Everyone says: “Just use let and const, never var.” Today I finally understood why. Variables already managed to confuse me once. Here’s what I explored today. Variables in JavaScript: -Variables store data so we can use it later in our program. There are three ways to create them: 1️⃣ var The old way. It’s function-scoped and gets hoisted, which can sometimes cause confusing behavior. 2️⃣ let Modern and block-scoped. You can change the value later. let score = 10; score = 20; 3️⃣ const Also block-scoped, but the value cannot be reassigned. const name = "Shobhit"; One interesting thing I learned: Even if a variable is declared with const, objects inside it can still be modified. Another surprising discovery: typeof null returns "object". This is actually a long-standing JavaScript bug from the early days of the language. It stayed because changing it would break too many websites. My rule going forward: Use const by default. Use let when the value needs to change. Avoid var. Day 2 done. Slowly understanding how JavaScript actually works. What confused you the most when you first learned JavaScript? #JavaScript #LearningInPublic #WebDevelopment #100DaysOfCode #Frontend
To view or add a comment, sign in
-
-
🚀 Day 7/100 of #100DaysOfCode Today was all about strengthening JavaScript fundamentals — revisiting concepts that seem simple but are often misunderstood. 🔁 map() vs forEach() Both are used to iterate over arrays, but they serve different purposes: 👉 map() Returns a new array Used when you want to transform data Does not modify the original array Example: const doubled = arr.map(num => num * 2); 👉 forEach() Does not return anything (undefined) Used for executing side effects (logging, updating values, etc.) Often modifies existing data or performs actions Example: arr.forEach(num => console.log(num)); ⚔️ Key Difference: Use map() when you need a new transformed array Use forEach() when you just want to loop and perform actions ⚖️ == vs === (Equality in JS) 👉 == (Loose Equality) Compares values after type conversion Can lead to unexpected results Example: '5' == 5 // true 😬 👉 === (Strict Equality) Compares value AND type No type coercion → safer and predictable Example: '5' === 5 // false ✅ 💡 Takeaway: Small concepts like these make a big difference in writing clean, bug-free code. Mastering the basics is what separates good developers from great ones. 🔥 Consistency > Intensity On to Day 8! #JavaScript #WebDevelopment #CodingJourney #LearnInPublic #Developers #100DaysOfCode #SheryiansCodingSchool #Sheryians
To view or add a comment, sign in
-
-
🚀 Today’s JavaScript Practice: Merging Two Arrays Using a For Loop Today I practiced how to merge two arrays in JavaScript using a for loop instead of built-in methods. This helped me better understand how array indexing and loops work internally. 🔹 First, I created two arrays with some numbers. 🔹 Then I used a for loop to copy elements from the first array into a new array. 🔹 After that, I used another for loop to add elements of the second array after the first array’s elements. 💻 Example idea: data1 = [10,20,30,40,50] data2 = [60,70,80,90,100] ✅ Result → [10,20,30,40,50,60,70,80,90,100] You can also check my GitHub profile for more practice projects and code. #DSA #JavaScript #WebDevelopment #CodingPractice 😊
To view or add a comment, sign in
-
🚀 30 Days of JavaScript – Day 16 Starting to build more structured programs using JavaScript. 💡 Today’s Project: Contact Manager This program allows users to: • Add contacts (name & phone) • View stored contacts 🧠 Concepts Used: • functions • arrays of objects • oops • menu-driven logic This helped me understand how to organize code into reusable functions. 🎥 Demo below 👇 Full source code in the First comment. #JavaScript #WebDevelopment #CodingJourney #LearningJavaScript #ProblemSolving
To view or add a comment, sign in
-
✨ 𝗗𝗮𝘆 𝟭𝟳 𝗼𝗳 𝗠𝘆 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗝𝗼𝘂𝗿𝗻𝗲𝘆 🚀 Today I explored one of the most important concepts in JavaScript: the 𝗘𝘃𝗲𝗻𝘁 𝗟𝗼𝗼𝗽. I learned why 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗶𝘀 𝘀𝗶𝗻𝗴𝗹𝗲-𝘁𝗵𝗿𝗲𝗮𝗱𝗲𝗱 𝗮𝗻𝗱 𝘀𝘆𝗻𝗰𝗵𝗿𝗼𝗻𝗼𝘂𝘀, yet still capable of handling asynchronous tasks efficiently. Key ideas I understood: 🔹 𝗦𝗶𝗻𝗴𝗹𝗲-𝘁𝗵𝗿𝗲𝗮𝗱𝗲𝗱 𝗻𝗮𝘁𝘂𝗿𝗲 – JavaScript runs one task at a time on a single call stack. 🔹 𝗦𝘆𝗻𝗰𝗵𝗿𝗼𝗻𝗼𝘂𝘀 𝗲𝘅𝗲𝗰𝘂𝘁𝗶𝗼𝗻 – code runs line by line by default. 🔹 𝗘𝘃𝗲𝗻𝘁 𝗟𝗼𝗼𝗽 – manages asynchronous operations by coordinating the 𝗖𝗮𝗹𝗹 𝗦𝘁𝗮𝗰𝗸, 𝗪𝗲𝗯 𝗔𝗣𝗜𝘀, 𝗮𝗻𝗱 𝗖𝗮𝗹𝗹𝗯𝗮𝗰𝗸 𝗤𝘂𝗲𝘂𝗲. This concept finally helped me understand how JavaScript handles things like 𝘁𝗶𝗺𝗲𝗿𝘀, 𝗲𝘃𝗲𝗻𝘁𝘀, 𝗮𝗻𝗱 𝗮𝘀𝘆𝗻𝗰𝗵𝗿𝗼𝗻𝗼𝘂𝘀 𝗼𝗽𝗲𝗿𝗮𝘁𝗶𝗼𝗻𝘀 without blocking the main thread. #JavaScript #100DaysOfCode #WebDevelopment #LearningJourney #FrontendDevelopment #EventLoop
To view or add a comment, sign in
-
-
🚀 JavaScript Fundamentals Series — Part 8 Objects are one of the most important concepts in JavaScript. Almost everything in JavaScript is built around objects. This guide covers: • What objects really are • Properties and methods • How JavaScript structures data • Why objects are everywhere in JS If you want to truly understand JavaScript, you must understand objects. Full guide 👇 https://lnkd.in/dGHh7weZ #javascript #coding #webdev
To view or add a comment, sign in
-
⚠️ The Danger of Splicing Arrays in a Loop "While solving the 'Move Zeroes' challenge today, I encountered a classic JavaScript pitfall: Modifying an array's length while iterating over it. The Mistake: Using .splice() inside a for loop. When you remove an element, the next one shifts left, and your loop index skips it! The Lesson: Always adjust your index or, even better, use the Two-Pointer technique. It's not just safer; it's much more performant for large datasets. Small bugs teach the biggest lessons! 🚀" "Did you know? JavaScript (ES6) allows you to swap array elements in a single line using destructuring : [a, b] = [b, a]. Clean, readable, and efficient!" Feel free to check out my progress and solutions on my LeetCode profile: I've shared my LeetCode profile link in the first comment below! #JavaScript #CodingTips #WebDevelopment #ProblemSolving #LeetCode #AngularDeveloper
To view or add a comment, sign in
-
-
🚀 30 Days of JavaScript – Day 6 Continuing my journey to improve my JavaScript logical thinking by building small programs every day. 💡 Today’s Program: Find the Largest Number (User Input) This program allows the user to enter numbers separated by commas and then finds the largest number in the list. 🧠 Concepts Used: • prompt() for user input • split() to convert input into an array • map(Number) to convert strings into numbers • for loop for iteration • Conditional comparison (if statement) 📌 Example Input: 10,25,7,90,30 Output: Largest Number: 90 🎥 Demo below 👇 Full source code in the First comment. #JavaScript #WebDevelopment #CodingJourney #ProblemSolving #LearningJavaScript #30DaysOfCode
To view or add a comment, sign in
-
🚀 Just finished building my JavaScript Complete Theory Notes / Cheat Sheet 📘⚡ Over the past few days, I compiled a structured roadmap of JavaScript concepts covering everything from fundamentals to advanced topics. Here’s what I included 👇 🔹 Variables & Data Types 🔹 Operators, Type Coercion & Control Flow 🔹 Functions, Scope, Closures & Hoisting 🔹 this keyword and prototypes 🔹 Arrays, Objects, Maps & Sets 🔹 ES6+ features like Destructuring, Spread, Rest, Modules 🔹 Async JavaScript (Callbacks, Promises, Async/Await, Event Loop) 🔹 DOM Manipulation & Event Handling 🔹 Web APIs, Storage, and Modern JS Patterns What started as simple revision notes slowly turned into a complete developer reference guide. The best part? While writing this, I didn’t just memorize syntax, I started understanding how JavaScript actually thinks behind the scenes: ⚡ Call Stack ⚡ Heap Memory ⚡ Event Loop ⚡ Microtasks vs Macrotasks Learning never stops. Next step: applying these concepts in real-world projects and interview-focused problem solving 💻🔥 #JavaScript #WebDevelopment #FrontendDeveloper #ReactJS #FullStackDeveloper #CodingJourney #SoftwareDevelopment #LearningInPublic #TechJourney
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