forked from liammclennan/JavaScript-Koans
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabout_scope.js
More file actions
21 lines (16 loc) · 790 Bytes
/
about_scope.js
File metadata and controls
21 lines (16 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
module("About Scope (topics/about_scope.js)");
thisIsAGlobalVariable = 77;
test("global variables", function() {
equal(77, thisIsAGlobalVariable, 'is thisIsAGlobalVariable defined in this scope?');
});
test("variables declared inside of a function", function() {
var outerVariable = "outer";
// this is a self-invoking function. Notice that it calls itself at the end ().
(function() {
var innerVariable = "inner";
equal('outer', outerVariable, 'is outerVariable defined in this scope?');
equal('inner', innerVariable, 'is innerVariable defined in this scope?');
})();
equal('outer', outerVariable, 'is outerVariable defined in this scope?');
equal('undefined', typeof(innerVariable), 'is innerVariable defined in this scope?');
});