JS: Spread və Rest sintaks | Spread and Rest syntax in Javascript
HTML-код
- Опубликовано: 16 сен 2024
- JavaScript dilində SPREAD və REST operatorları, eyni sintaksis istifadə edilərək (...), müxtəlif məqsədlər üçün istifadə olunur. Hər ikisi ES6 (ECMAScript 2015) ilə təqdim edilmişdir. Onların istifadəsi çox faydalıdır, çünki kodu daha sadə və oxunaqlı edir. Gəlin hər ikisini daha ətraflı araşdıraq:
SPREAD Operatoru
SPREAD operatoru, massiv və ya obyektin elementlərini ayrı-ayrılıqda yaymaq üçün istifadə olunur. Bu operator, bir massiv və ya obyektin elementlərini "yayıb" ayrı-ayrı dəyərlər kimi təqdim etməyə imkan verir.
REST Operatoru
REST operatoru, funksiya parametrlərini və ya massiv və obyektin qalan elementlərini bir araya toplamaq üçün istifadə olunur. Bu operator ilə, funksiyanın geri qalan argümentlərini və ya obyektin qalan hissələrini tutmaq mümkündür.
======
The SPREAD and REST operators in JavaScript use the same syntax (...) but serve different purposes. Both were introduced with ES6 (ECMAScript 2015) and are very useful for making code simpler and more readable. Let's explore both in more detail:
SPREAD Operator
The SPREAD operator is used to spread out the elements of an array or object. This operator allows you to "spread" the elements of an array or object into individual elements.
REST Operator
The REST operator is used to gather function parameters or the remaining elements of an array or object. This operator allows you to capture the remaining arguments of a function or the remaining elements of an object.
#kody_az #kodyaz #js #javascript #nodejs #es6 #viral #viralcode #viralvideo #random #code #coder #azerbaycan #azerbaijan #baku #baki #programming #programmer #codes #hazırlıq #hazirliq #kurs #kurslar #course #courses #online #onlinecourses #test #quiz
təşəkkürlər müəllim
Super
salam mellim zehmet olmasa arxadaki musiqini sesini azaltsaniz ve ya hec qoymasaz olar ?