Files
ladybird/Tests/LibJS/AST/input/named-function-expr-scope.js
Andreas Kling f7c961136f Tests/LibJS: Add AST dump test cases
Add 39 test cases exercising AST dump output and scope analysis.
Tests cover local/global identifier marking, eval/with poisoning,
destructuring, closures, hoisting, classes, generators, and more.
2026-02-10 02:05:20 +01:00

28 lines
593 B
JavaScript

// Named function expression: the name is local to the function body,
// not visible outside.
var f = function myFunc() {
return myFunc;
};
// The name binding is immutable and doesn't leak.
var g = function gName(x) {
return gName(x - 1);
};
// Named function expression inside another function.
function outer() {
var inner = function innerName() {
return innerName;
};
return inner;
}
// Recursive named function expression with closure.
function make_counter() {
let count = 0;
return function tick() {
count++;
return tick;
};
}