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
22 lines (16 loc) · 781 Bytes
/
about_scope.js
File metadata and controls
22 lines (16 loc) · 781 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module("About Scope (topics/about_scope.js)");
thisIsAGlobalVariable = 77;
test("global variables", function() {
equals(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";
equals(outerVariable, __, 'is outerVariable defined in this scope?');
equals(innerVariable, __, 'is innerVariable defined in this scope?');
})();
equals(outerVariable, __, 'is outerVariable defined in this scope?');
equals(typeof(innerVariable), "undefined", 'is innerVariable defined in this scope?');
});