#!/usr/local/bin/node function foo() { var a = 1; return function () { console.log(a); }; } var x = foo(); x(); // 1