mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-29 22:42:52 +00:00
LibJS: Get initial_value from local variables if id represents a local
If identifier represents local variable we should get its value from `local_variables` in `ExecutionContext` instead of environment.
This commit is contained in:
parent
675d919dd2
commit
a4a94de942
Notes:
sideshowbarker
2024-07-17 10:31:19 +09:00
Author: https://github.com/kalenikaliaksandr
Commit: a4a94de942
Pull-request: https://github.com/SerenityOS/serenity/pull/21141
2 changed files with 14 additions and 1 deletions
|
@ -151,3 +151,12 @@ test("use variable as default function parameter", () => {
|
|||
|
||||
expect(func()).toBe(a);
|
||||
});
|
||||
|
||||
test("variable is initialized to the value of the parameter if one with the same name exists", () => {
|
||||
function func(a = 1) {
|
||||
var a;
|
||||
return a;
|
||||
}
|
||||
|
||||
expect(func()).toBe(1);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue