mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:38:11 +00:00
js: Fix simple scopes example
Weirdly enough, the "simple-scopes" test doesn't return undefined anymore, at first I thought the scoping was somehow broken, turns out the interpreter doesn't consider the returned y as the last evaluated value anymore, possibly because it's undefined (?).
This commit is contained in:
parent
dfbaa8e543
commit
6780d70fb1
1 changed files with 4 additions and 2 deletions
|
@ -1,9 +1,11 @@
|
|||
//I should return `undefined` because y is bound to the inner-most enclosing function, i.e the nested one (bar()), therefore, it's undefined in the scope of foo()
|
||||
function foo() {
|
||||
function bar() {
|
||||
var y = 6;
|
||||
}
|
||||
|
||||
bar()
|
||||
bar();
|
||||
return y;
|
||||
}
|
||||
foo(); //I should return `undefined` because y is bound to the inner-most enclosing function, i.e the nested one (bar()), therefore, it's undefined in the scope of foo()
|
||||
|
||||
print(foo());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue