mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:17:44 +00:00
LibJS: Function.length respects default and rest parameters
"[Function.length is] the number of formal parameters. This number excludes the rest parameter and only includes parameters before the first one with a default value." - MDN
This commit is contained in:
parent
2c14714ee0
commit
838390171c
6 changed files with 43 additions and 15 deletions
|
@ -11,6 +11,16 @@ try {
|
|||
assert((bar.length = 5) === 5);
|
||||
assert(bar.length === 3);
|
||||
|
||||
function baz(a, b = 1, c) {}
|
||||
assert(baz.length === 1);
|
||||
assert((baz.length = 5) === 5);
|
||||
assert(baz.length === 1);
|
||||
|
||||
function qux(a, b, ...c) {}
|
||||
assert(qux.length === 2);
|
||||
assert((qux.length = 5) === 5);
|
||||
assert(qux.length === 2);
|
||||
|
||||
console.log("PASS");
|
||||
} catch (e) {
|
||||
console.log("FAIL: " + e);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue