Nullish coalescing in TypeScript | ?? operator tutorial | null, undefined and default value #kody_az
Nullish coalescing TypeScript-də ?? operatoru ilə yazılır və default dəyər vermək üçün istifadə olunur. Bu operator sol tərəfdəki dəyəri yoxlayır və əgər həmin dəyər null və ya undefined olarsa, sağ tərəfdəki dəyəri götürür. Əgər sol tərəfdə 0, false və ya boş string "" varsa, ?? onları dəyişmir, çünki bunlar real dəyərlər hesab olunur. Bu xüsusiyyətinə görə ?? operatoru çox vaxt || operatorundan daha təhlükəsizdir. Məsələn, məhsulun endirimi 0 ola bilərsə, discount ?? 10 yazmaq discount || 10 yazmaqdan daha doğrudur. Çünki 0 burada “endirim yoxdur” mənasını verən real dəyərdir və default dəyərlə əvəz olunmamalıdır. Nullish coalescing əsasən API-dən gələn məlumatlarda, istifadəçi formalarında, konfiqurasiya fayllarında və optional property-lərlə işləyərkən çox faydalıdır. O, optional chaining ?. ilə birlikdə də tez-tez istifadə olunur, məsələn user.profile?.city ?? "Şəhər məlum deyil". Bu kod o deməkdir ki, əgər istifadəçinin şəhər məlumatı yoxdursa, proqram xəta vermədən default mətn göstərəcək. Qısa desək, ?? operatoru yalnız həqiqətən dəyər olmayan hallarda, yəni null və undefined olduqda ehtiyat dəyər seçmək üçün istifadə olunur. ===== Nullish coalescing in TypeScript is written with the ?? operator, and it is used to provide a default value. This operator checks the value on the left side, and if that value is null or undefined, it returns the value on the right side. If the left side contains 0, false, or an empty string "", the ?? operator does not replace them, because they are considered real values. Because of this, ?? is often safer than the || operator. For example, if a product discount can be 0, writing discount ?? 10 is better than writing discount || 10. That is because 0 can mean “no discount”, so it is a valid value and should not be replaced by a default value. Nullish coalescing is very useful when working with data from APIs, user forms, configuration files, and optional object properties. It is also often used together with optional chaining ?., for example user.profile?.city ?? "Unknown city". This code means that if the user’s city information does not exist, the program will show a default text without causing an error. In short, the ?? operator is used to choose a fallback value only when the original value is really missing, meaning it is null or undefined. #kody_az #kodyaz #js #typescript #nodejs #es6 #ts #viral #viralcode #viralvideo #code #coder #azerbaycan #azerbaijan #baku #baki #programming #programmer #hazırlıq #hazirliq #kurs #kurslar #course #courses #online #onlinecourses

Aesthetic Aura Background 3 hours

Lanz lässt Bombe platzen: "Warum geht ihr dann nicht zurück"?❗️

Objects in TypeScript | methods in object | oprtionals & type alias | readonly #kody_az

Mən özümü necə test edim? | özümü necə yolxaya bilərəm? | How to test yourself? #kody_az

21 narmativ

Functions in TypeScript | optional parameters, void, local variables, implicit returns #kody_az

Type alias and types in TypeScript | union inersection literal and null types #kody_az

Python Darslari #12 | str metodlari | 1-qism

Creator of C++: Bell Labs, Negative Overhead Abstraction, Mistakes | Bjarne Stroustrup

Tələskənlik və təcrübə mövzusu | being in a rush & experience | Bugs Time #kody_az

She’s 12. She Sings Aretha Franklin… Until Simon TELLS Her to Do It Acapella! 😳

TypeScript vs JavaScript | new course TypeScript | static typing | compiling to JavaScript #kody_az

AI Voice Generator in Python | Text To Speech (TTS) with Google AI Studio | Step-by-Step #kody_az

System Design Course – APIs, Databases, Caching, CDNs, Load Balancing & Production Infra

Compress and Decompress in Python | Interview algorithm | Live Coding AABBATTZ = 2A2B1A2T1Z #kody_az

ASMR Best Triggers For Sleep Collection (No Talking) 3 Hours of Tapping & Scratching

263 DIOS TE DICE HOY: ESA ANGUSTIA QUE TE ROBA LA PAZ SERÁ CAMBIADA POR DESCANSO

How to Actually Build Mobile Apps with AI in 2026 | A Complete Beginner's Tutorial

Types in TypeScript | any, enum, tuple, primitive data types | NodeJS & type annotations #kody_az

