Files
rust_browser/tests/external/js262/fixtures/arrow-function-iife.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
480 B
JavaScript

// Arrow functions can be immediately invoked (IIFE pattern).
// Basic IIFE: no params.
console.log((() => 42)());
// IIFE with a single param.
console.log((x => x * 2)(6));
// IIFE with multiple params.
console.log(((a, b) => a + b)(3, 4));
// IIFE with a block body and explicit return.
console.log(((x) => { return x * x; })(5));
// Nested IIFE: inner arrow is immediately invoked inside outer arrow body.
var result = ((a) => ((b) => a + b)(10))(5);
console.log(result);