Spread Operator, Rest and Default parameters | FastCode #5 | [in Arabic]

preview_player
Показать описание
In This Episode, I'm talking about the new spread operator in ES6 and the Rest parameters and how it's way much better than the arguments object, and finally talking about the default parameters and a good use case for it.

SemiColonAcademy page on Facebook (discussions there):

Github Repo:

ماتنسوش تشتركوا في القناة وتفعلوا جرس التنبيهات عشان يوصلكم كل جديد ✌️

صفحة الفيس بوك

اكونت تويتر
Рекомендации по теме
Комментарии
Автор

أستاذي
ليش حطيت type في الباراميتر و هي صارت تمثل سترينغ numbers؟
يا ريت تجاوبني لو سمحت

maher.alshaar
Автор

أستاذي شرحك كتير حلو و رائع
بس والله عم تستعجل بالشرح
يا ريت تطول بالك علينا شوي ❤️🌹😘 تحياتي أحلى جار

maher.alshaar
Автор

*/
function sum(x, y, z) {
return x + y + z;
}

const inputs = [1, 2, 3];

console.log(sum(...inputs)); // 6
// 3

// copying arrays
let arr = [1, 2, 3];
let copiedArr = [...arr]; // deep copy
copiedArr.push(4);
console.log(arr); //[ 1, 2, 3 ]
console.log(copiedArr); // [ 1, 2, 3, 4 ]

// merging arrays
let cities = ['San Francisco', 'Los Angeles'];
let places = ['Miami', ...cities, 'Chicago'];
console.log(places); // [ 'Miami', 'San Francisco', 'Los Angeles', 'Chicago' ]

*/
function logArguments(type, base, ...args) {
console.log(args);
for (let i of args) {
console.log(i);
}
}

//the below will print => 'numbers' 'base 10' 1 2 3 4 5 i <= in the console
logArguments('numbers', 'base 10', 1, 2, 3, 4, 5);

*/
const pi = 22 / 7;
function circleArea(radius, decimalLength = 2) {
return (pi * Math.pow(radius, 2)).toFixed(decimalLength);
}

console.log(circleArea(3)); // 28.29

AmmarOuds
join shbcf.ru