rest vs spread operator javascript code example
Example 1: javascript rest parameters vs spread operator
function foo (...args) { console.log(args) }
foo(1,2,3,4,5,6)
let arr = [1, 2, 3];
let arrCopy = [-1, 0, ...arr];
Example 2: spread and rest operator javascript
var myName = ["Marina" , "Magdy" , "Shafiq"] ;const [firstName , ...familyName] = myName ;console.log(firstName);
Example 3: spread operator javascript
[a, b, ...objIteravel] = [1, 2, 3, 4, 5];
Example 4: spread and rest operator javascript
function myData(...args){console.log(args) ;