Optional Chaining & Safe Access
Optional chaining (?.) prevents errors when accessing properties that might not exist. It's essential for handling incomplete or variable data structures.
The Problem
Basic Optional Chaining
Optional Chaining with Arrays
Optional Method Calls
Nullish Coalescing (??)
Combine ?. with ?? for default values:
Exercise: Safe Navigation
Exercise: Array Safety
Key Points
?.stops and returnsundefinedif value is null/undefined- Works with properties:
obj?.prop - Works with arrays:
arr?.[0] - Works with methods:
fn?.() - Combine with
??for default values ??only replaces null/undefined, not falsy values
التالي · الدرس 11 من 23
Transforming with map()
قراءة 1 دقيقة
أنهيت 10 من 23 درسًا

اسأل Byte عن هذا الدرس
محادثة خاصة حول هذا الدرس. قرأ Byte الدرس كاملًا، ويجيب خلال ثوانٍ، ويُظهر القسم الذي تأتي منه كل إجابة. يمكنك السؤال بأي لغة.
الأسئلة والأجوبة
أسئلة عامة حول هذا الدرس. يجيب AI Tutor فورًا بلغتك، ويراجع فريق FreeAcademy الإجابات، ويمكن لكل المتعلمين قراءتها.

