closure example (simple)
by hellosze
JavaScript
function sayHello2(name) {
var text = 'Hello ' + name; // Local variable
var sayAlert = function() { alert(text + "111"); }
return sayAlert;
}
say2 = sayHello2('Bob');
say2(); // alerts "Hello Bob"