How to use the spread operator to pass an array of arguments to a function in Node.js

1 Answer

0 votes
function PrintAll(a, b, c, d, e) {
    console.log(a, b, c, d, e);
}
 
const args = [1, 'b', 3.14, 90, 5, 6, 7];
 
PrintAll(...args); 
  
  
/*
run:
  
1 b 3.14 90 5
  
*/

 



answered Jan 24, 2025 by avibootz
...