MCPcopy Create free account
hub / github.com/basarat/typescript-book / outerFunction

Function outerFunction

code/javascript/closure.ts:1–10  ·  view source on GitHub ↗
(arg)

Source from the content-addressed store, hash-verified

1function outerFunction(arg) {
2 var variableInOuterFunction = arg;
3
4 function bar() {
5 console.log(variableInOuterFunction); // Access a variable from the outer scope
6 }
7
8 // Call the local function to demonstrate that it has access to arg
9 bar();
10}
11
12outerFunction("hello closure"); // logs hello closure!
13

Callers 1

closure.tsFile · 0.70

Calls 2

barFunction · 0.70
logMethod · 0.45

Tested by

no test coverage detected