New course! Every coder should learn Generative AI!
Try a free lesson+ 3
I don't understand your question.
The spread operator spreads the values of an array or object into an iterable 'list'.
const arr = [1, 2, 3];
const arr2 = [...arr, 4, 5];
console.log(arr2);
//1, 2, 3, 4, 5
I think you are referring to rest parameters. Rest transform the arguments provided into an array.
function rest(...args) {
console.log(args[2]);
}
rest(1, 2, 3, 4);
//Outputs 3