mirror of
https://github.com/hanzoai/babel.git
synced 2026-09-24 16:56:45 +00:00
13 lines
288 B
JavaScript
13 lines
288 B
JavaScript
function f1(a, ...rest) {
|
|
let b = rest[rest.length - 3];
|
|
let c = rest[rest.length - 2];
|
|
let d = rest[rest.length - 1];
|
|
return [a, b, c, d];
|
|
}
|
|
expect(f1(1, 2)).toEqual([1, undefined, undefined, 2]);
|
|
|
|
function f2(a, ...rest) {
|
|
return rest[-1];
|
|
}
|
|
expect(f2(1, 2)).toBeUndefined();
|