Skip to content

Instantly share code, notes, and snippets.

@zladuric
Created January 24, 2017 15:19
Show Gist options
  • Save zladuric/dae9dc89297921f4f4023dee53e667fd to your computer and use it in GitHub Desktop.
Save zladuric/dae9dc89297921f4f4023dee53e667fd to your computer and use it in GitHub Desktop.
// Demonstrating a point for: http://stackoverflow.com/questions/41814637/javascript-function-definition-explanation/41814751?noredirect=1#comment70848676_41814751
> [zlatko@zlatko-desktop ~]$ node
> function outer() {
... set();
... (function set() {})();
... }
undefined
> outer()
ReferenceError: set is not defined
at outer (repl:2:1)
at repl:1:1
at sigintHandlersWrap (vm.js:22:35)
at sigintHandlersWrap (vm.js:96:12)
at ContextifyScript.Script.runInThisContext (vm.js:21:12)
at REPLServer.defaultEval (repl.js:313:29)
at bound (domain.js:280:14)
at REPLServer.runBound [as eval] (domain.js:293:12)
at REPLServer.<anonymous> (repl.js:513:10)
at emitOne (events.js:101:20)
> function outer2() {
... (function set() {})();
... set();
... }
undefined
> outer2()
ReferenceError: set is not defined
at outer2 (repl:3:1)
at repl:1:1
at sigintHandlersWrap (vm.js:22:35)
at sigintHandlersWrap (vm.js:96:12)
at ContextifyScript.Script.runInThisContext (vm.js:21:12)
at REPLServer.defaultEval (repl.js:313:29)
at bound (domain.js:280:14)
at REPLServer.runBound [as eval] (domain.js:293:12)
at REPLServer.<anonymous> (repl.js:513:10)
at emitOne (events.js:101:20)
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment