POST #16 - JavaScript Optional Chaining Advanced 💎 Optional Chaining with Functions Did you know you can use ?. with functions? onSubmit?.(data); // Only calls if onSubmit exists obj.method?.(); // Only calls if method exists callbacks.forEach?.(cb => cb()); // Only runs if forEach exists Safer code with less checks. #JavaScript #Programming #WebDev #CleanCode
Muhammad Zulqarnain’s Post
More Relevant Posts
-
𝗪𝗲𝗹𝗰𝗼𝗺𝗲 𝘁𝗼 𝗗𝗮𝘆 𝟭𝟭 𝘑𝘢𝘷𝘢𝘚𝘤𝘳𝘪𝘱𝘵 𝘥𝘰𝘦𝘴𝘯’𝘵 𝘶𝘴𝘦 𝘤𝘭𝘢𝘴𝘴𝘪𝘤𝘢𝘭 𝘪𝘯𝘩𝘦𝘳𝘪𝘵𝘢𝘯𝘤𝘦. 𝘐𝘵 𝘶𝘴𝘦𝘴 𝘰𝘣𝘫𝘦𝘤𝘵-𝘵𝘰-𝘰𝘣𝘫𝘦𝘤𝘵 𝘥𝘦𝘭𝘦𝘨𝘢𝘵𝘪𝘰𝘯. Every property access walks the prototype chain — and that single mechanism explains: • how methods are shared • Why memory usage stays low • how classes and frameworks actually work If you understand this, JavaScript stops feeling “magical” and starts feeling predictable. #JavaScript #WebDevelopment #SoftwareEngineering #Frontend #InterviewPrep #Programming
To view or add a comment, sign in
-
-
JavaScript Array Methods You Should Master: .map() - Transform elements .filter() - Select elements .reduce() - Combine elements .find() - Locate element .some() - Test condition Master these and you'll write cleaner, more functional code. No more messy for loops. #JavaScript #CleanCode #Programming
To view or add a comment, sign in
-
🔴 Stop Using any in #TypeScript The Problem with any: ❌ Disables ALL type checking ❌ Defeats TypeScript's purpose ❌ Bugs slip into production The Power of unknown: ✅ Forces type validation ✅ Catches errors at compile time ✅ Type-safe by default My rule of thumb: If you're reaching for any, ask yourself: "Do I really not know the type, or am I just being lazy?" 💡 99% of the time, unknown is the answer #TypeScript #JavaScript #WebDevelopment #SoftwareEngineering #FrontendDevelopment #Programming #CleanCode #DeveloperTips #CodingLife #TechCareers
To view or add a comment, sign in
-
-
Use the JavaScript `Gamepad API` to display real-time connection status and button states of game controllers 🔥 Do Like 👍 & Repost 🔄 #html #css #javascript #100daysofcode #webdevelopment #programming
To view or add a comment, sign in
-
Today I tripped over a small JavaScript detail that turned into a solid reminder about how explicit control flow really is. I wrote a 'for' loop intending to move the index by 2 on each iteration: for(let i = 0; i < 8; i + 2) Looked fine at a glance but the loop never progressed. The reason was simple (and humbling): 'i + 2' is just an expression. It does not mutate state. The loop counter never changed, so I ended up with an infinite loop. The correct versions were: i = i + 2 //explicit assignment i += 2 // idiomatic What this reinforced for me: 1. JavaScript will not "do what you mean", it will only what you explicitly tell it 2. Expressions are not equal to assignments 3. Loop mechanics matter more than the logic inside the loop Small mistake, but a good reminder that clarity beats assumption every time. #JavaScript #LeetCode #LearningInPublic #Debugging #Programming
To view or add a comment, sign in
-
Use CSS "scroll-padding-top" to add space at the top so nothing gets hidden when you scroll 🔥 Hope this helps ✅️ Do Like 👍 & Repost 🔄 #html #css #javascript #100daysofcode #webdevelopment #programming
To view or add a comment, sign in
-
Mastering JavaScript Basics: Closures, Hoisting, and the this Keyword Dive into three foundational JavaScript concepts—closures, hoisting, and the this keyword—with practical examples and clear explanations. Learn how they work under the hood and how to use them effectively in real-world applications. Read the full article 👇 https://lnkd.in/gqxZjUW7 #Programming #WebDevelopment #SoftwareEngineering #Technology #Coding #JavaScript #JSClosures #JSHoisting #ThisKeyword #FrontEndDevelopment #FutureOfWork
To view or add a comment, sign in
-
-
Object Literal is one of the most common and convenient ways to create objects in JavaScript. It’s basically a way to define an object directly using curly braces {} — no classes, no constructors, no new keyword needed. #object #react #javascript #coding #programming #DSA
To view or add a comment, sign in
-
-
Practiced the difference between normal functions and arrow functions in JavaScript. => In a normal function, this refers to the object calling it => In an arrow function, this does not bind to the object Understanding this behavior helps avoid many silent bugs in JavaScript. #JavaScript #JavaScriptBasics #ArrowFunctions #ThisKeyword #WebDevelopment #FrontendDevelopment #LearningInPublic #CodingJourney #100DaysOfCode #BuildInPublic #DeveloperLife #Programming
To view or add a comment, sign in
-
-
Hoisting in JavaScript Declarations get moved to the top at runtime. Knowing what gets hoisted and what doesn’t saves you from very confusing undefined errors. #programming #code #javascript
To view or add a comment, sign in
Explore related topics
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