TypeScript vs JavaScript | new course TypeScript | static typing | compiling to JavaScript #kody_az
Dərs haqqında
TypeScript əslində JavaScript-in üzərinə əlavə olunmuş imkanlar toplusudur və əsas məqsədi kodu daha təhlükəsiz və daha oxunaqlı etməkdir. Onun ən böyük üstünlüyü tipləmə (static typing)-dir: dəyişənlərin, funksiyaların və obyektlərin hansı tipdə olduğunu əvvəlcədən göstərdiyin üçün bir çox səhvi proqramı işlətməzdən əvvəl editorun özü tapır. Buna görə də autocomplete, ipucları və refactor prosesi daha rahat olur. TypeScript xüsusən böyük layihələrdə çox faydalıdır, çünki kod bazasını idarə etmək, dəyişiklik etmək və səhvləri azaltmaq daha asanlaşır. O, interface və type kimi imkanlarla obyektlərin quruluşunu və funksiyaların “müqaviləsini” dəqiq təsvir etməyə kömək edir, bu da komanda işində hamının eyni qaydalara uyğun yazmasını təmin edir. Həmçinin TypeScript modern JavaScript xüsusiyyətlərini istifadə edib, lazım gələrsə daha köhnə mühitlər üçün uyğun JavaScript-ə çevirə bilir. Əsas fərq ondadır ki, JavaScript birbaşa brauzerdə və ya Node.js-də işləyir, TypeScript isə adətən əvvəlcə JavaScript-ə compile olunur, sonra işləyir. JavaScript daha sərbəstdir, amma bəzi xətalar yalnız runtime-da üzə çıxır (məsələn, mövcud olmayan obyektin metodunu çağırmaq), TypeScript isə çox vaxt bunu əvvəldən xəbərdar edir. Nəticədə isə TypeScript ayrıca bir dünya deyil: yazdığın TS kodu sonda yenə də sadə JavaScript kimi işləyir.
=====
TypeScript is basically JavaScript with extra features that help you write safer and cleaner code. Its main advantage is static typing, which lets your editor and tools catch many mistakes before you even run the program. Because types describe what your data should look like, you get much better autocomplete, clearer hints, and easier refactoring. TypeScript is especially useful in big projects, where keeping code organized and maintainable matters a lot. It also gives you features like interfaces and type aliases to describe objects and function contracts in a clear way, which makes teamwork smoother because everyone follows the same “rules” for using code. Another benefit is that TypeScript can use modern JavaScript features while still compiling to JavaScript that works in older environments if you need compatibility. The key difference is that JavaScript runs directly in the browser or Node.js, while TypeScript is usually compiled first and then runs as JavaScript. JavaScript is flexible but can fail at runtime (for example, calling a method on something that doesn’t exist), whereas TypeScript often warns you earlier during development. Even with all these extras, TypeScript doesn’t replace JavaScript in the final result: TypeScript code always becomes plain JavaScript. So TypeScript is a “safer way to write JavaScript,” not a separate world.
#kody_az #kodyaz #js #javascript #typescript #ts #nodejs #es6 #viral #viralcode #nodejs #viralvideo #random #code #coder #azerbaycan #azerbaijan #baku #baki #programming #programmer #codes #hazırlıq #hazirliq #kurs #kurslar #course #courses #online #onlinecourses #test #quiz