Loading video player...
TypeScript-də obyektlər bizə real həyatda olan varlıqları bir struktur daxilində təsvir etməyə kömək edir. Obyektin içində bir-biri ilə əlaqəli məlumatlar, məsələn ad, yaş, identifikator və başqa xüsusiyyətlər birlikdə saxlanılır. Type alias isə bu obyekt quruluşuna xüsusi ad verməyə imkan yaradır və eyni tipi yenidən rahat istifadə etməyi asanlaşdırır. Beləliklə, kod həm daha səliqəli görünür, həm də daha aydın oxunur. Obyektlərin daxilində metodlar da ola bilər və bunlar obyektin yerinə yetirdiyi funksiyalar kimi işləyir. Məsələn, bir istifadəçi obyekti həm məlumat saxlaya, həm də salam vermək və ya öz məlumatını göstərmək kimi əməliyyatlar edə bilər. Optional xüsusiyyətlər o deməkdir ki, bəzi sahələrin olması mümkündür, amma onların yazılması mütləq deyil. Bu, xüsusilə e-poçt kimi bəzən olan, bəzən isə olmayan məlumatlar üçün çox faydalıdır. Readonly isə bir xüsusiyyətin ilkin dəyərinin verilməsinə icazə verir, amma sonradan onun dəyişdirilməsinin qarşısını alır. Bütün bunlar birlikdə TypeScript-də kodun daha təhlükəsiz, daha nizamlı və idarə olunmasının daha rahat olmasını təmin edir. ==== Objects in TypeScript let us represent real-world things by keeping related data together in one structure. A type alias gives a custom name to that structure, which makes the code easier to read and reuse. With a type alias, we can define what properties an object should have, such as a name, age, or id. Objects can also contain methods, which are functions inside the object that describe actions the object can perform. For example, an object may store information about a user and also include a method that greets another person or shows details about itself. TypeScript also supports optional properties, which means some values may exist but are not required when creating the object. This is useful when information like an email address is not always available. Another important feature is readonly, which allows a property to be set once and then protected from being changed later. This helps prevent accidental changes to important values such as identifiers. Together, objects, methods, optional properties, type aliases, and readonly fields make TypeScript code more organized, safer, and easier to understand. #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