function
sayHello
() {
var
say
=
function
() {
console
.
log
(hello); }
// Local variable that ends up within the closure
var
hello
=
'
Hello, world!
'
;
return
say;
}
var
sayHelloClosure
=
sayHello
();
sayHelloClosure
();
// ‘Hello, world!’
view raw
sayHello.js
hosted with ❤ by
GitHub