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) · 766 Bytes
/
about_scope.js
File metadata and controls
21 lines (16 loc) · 766 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(__, 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(__, outerVariable, 'is outerVariable defined in this scope?');
equal(__, innerVariable, 'is innerVariable defined in this scope?');
})();
equal(__, outerVariable, 'is outerVariable defined in this scope?');
equal(__, typeof(innerVariable), 'is innerVariable defined in this scope?');
});