object rest operator code example
Example 1: the rest operator javascript
function sum(...numbers) {
return numbers.reduce((accumulator, current) => {
return accumulator += current;
});
};
sum(1,2) // 3
sum(1,2,3,4,5) // 15
Example 2: spread and rest operator javascript
function myData(...args){console.log(args) ; // ["Marina",24,"Front-End Developer"]}myData("Marina",24,"Front-End Developer") ;