Looking at this MDN page on spread syntax it uses this example:
function myFunction(v, w, x, y, z) {
console.log(v);
console.log(w);
console.log(x);
console.log(y);
console.log(z);
}
const args = [0, 1];
myFunction(-1, ...args, 2, ...[3]);
I know ...args
copies the value of the items of args
(0, 1).
Looking at ...[3]
I see if I log it it resolves to 3
. But what is ...[3]
? How does it work, what is the purpose of it and why does it resolve to 3
?