From 6780d70fb1828575979810892256f2a763f05517 Mon Sep 17 00:00:00 2001 From: 0xtechnobabble <0xtechnobabble@protonmail.com> Date: Mon, 16 Mar 2020 01:17:24 +0200 Subject: [PATCH] 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 (?). --- Base/home/anon/js/simple-scopes.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Base/home/anon/js/simple-scopes.js b/Base/home/anon/js/simple-scopes.js index dcea148c25..8580a8c770 100644 --- a/Base/home/anon/js/simple-scopes.js +++ b/Base/home/anon/js/simple-scopes.js @@ -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());