java script Rest Parameters code example
Example 1: rest parameter javascript
function addition(...nombre) {
let resultat = 0
nombre.forEach(nombre => {
resultat+= nombre ;
});
console.log(resultat) ;
}
addition(4 ,9 ,5 ,415 ,78 , 54) ;
Example 2: spread and rest operator javascript
var myName = ["Marina" , "Magdy" , "Shafiq"] ;const [firstName , ...familyName] = myName ;console.log(firstName); // Marina ;console.log(familyName); // [ "Magdy" , "Shafiq"] ;