Files
rust_browser/tests/external/js262/fixtures/arrow-function-arity.js
Zachary D. Rowitsch 75bc30bb8e Add JavaScript arrow function (=>) support
Implement parsing, evaluation, lexical this capture, and new rejection
for arrow functions. Covers expression bodies, block bodies, zero/single/
multi-param forms, and backtracking disambiguation from grouping parens.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 22:12:47 -05:00

18 lines
512 B
JavaScript

// Arrow functions handle extra and missing arguments the same way as regular functions.
// Extra arguments beyond declared params are silently ignored.
var f1 = (x) => x;
console.log(f1(10, 20, 30));
// Missing arguments default to undefined.
var f2 = (x) => x;
console.log(f2());
// Two-param arrow: second arg missing → undefined.
var f3 = (a, b) => b;
console.log(f3(1));
// Zero-param arrow called with arguments: args ignored, expression still evaluated.
var f4 = () => 42;
console.log(f4(1, 2, 3));