ES6 and Typescript Tutorial - 14 - Spread Operator

preview_player
Показать описание

📱 Follow Codevolution

ES6 | ES2015 | Typescript | ES6 Tutorial | ES2015 Tutorial | Typescript Tutorial | ES6 Tutorial for Beginners | ES2015 Tutorial for Beginners | Typescript tutorial for Beginners
Рекомендации по теме
Комментарии
Автор

rest operator - in function paramter
spread operator - in function call
rest - combine (rest of all parameters are combined to a variable)
spread - split (arrays into individual elements)

vigneshgvs
Автор

means it's mandatory to use rest and spread ie ... in calling and ... in the declaration of the function when we pass an array of elements rather than multiple elements.

TomarSahabVlogs
Автор

Can't we call the function directly without spread operator and recieve argument without rest operator?

manikantapabba
Автор

What makes Spread operator different from passing a normal array to a function?

jawadzaib
Автор

Both methods are giving me same results
SPREAD OPERATOR

let displayColors = (msg: String, ...colors:any[]) => {
console.log(colors);

// for (let i in colors ){
// console.log(colors[i]);
// }
}

let colorsArray=["purple", "Indigo", "white"];
displayColors("I love Coding", ...colorsArray);


NORMAL ARRAY

let displayColors = (msg: String, colors:any[]) => {
console.log(colors);

// for (let i in colors ){
// console.log(colors[i]);
// }
}

let colorsArray=["purple", "Indigo", "white"];
displayColors("I love Coding", colorsArray);

sudhakararao