function fx(x,y,z) {
console.log( x, y, z );
}
fx( ...[1,2,3] );
|
function fx(...args) {
console.log( args );
}
fx( 1, 2, 3, 4, 5); //
|
Ici ... propage
|
Ici … rassemble
|
function foo(...args) {
args.shift();
args.push("BOB");
console.log( ...args );
}
foo("denis", "DUPONT");
Autre cas
function fx(x,...args) {
console.log( x, args );
}
fx( 1, 2, 3, 4, 5);
- "DUPONT"
- "BOB"
Autre cas
function fx(x,...args) {
console.log( x, args );
}
fx( 1, 2, 3, 4, 5);
- 1
- [2, 3, 4, 5]