-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path003.1-lexical.html
56 lines (52 loc) · 2.67 KB
/
003.1-lexical.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Closure</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- add Bootstrap CSS -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/global.css">
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
</head>
<body>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<!-- Page Content -->
<div class="container">
<div class="row">
<div class="col-lg-12 text-center">
<h1 id="message">Scope Closure</h1>
<p class="lead">Closure: Inception for variables.</p>
</div>
<div class="col-lg-12">
<blockquote>
<p>Closures are functions that refer to independent (free) variables. In other words, the function defined in the closure 'remembers' the environment in which it was created. -MDN</p>
</blockquote>
<ol>
<li>Open <kbd>js/003.1-closure.js</kbd> in Sublime Text.</li>
<li>Declare <code>name</code> as a local varible on line 6 and assign it a string that represents your name.</li>
<li>Uncomment the <code>alert</code> call on line 10.</li>
<li>Set the variable <code>name</code> as the parameter in the <code>alert</code> call.</li>
<li>On line 14, write a new function that logs the <code>name</code> variable in the console:
<pre>console.log(name);</pre>
</li>
<li>Invoke your new function inside the <code>displayName</code> function.</li>
</ol>
</div>
<div class="col-lg-12 text-center footer">
<ul class="list-unstyled">
<li><a href="002-lab.html"><< Prev</a> | <a href="003.2-lexical.html">Next >></a></li>
<li>Intermediate JavaScript & jQuery - <a href="https://twitter.com/ev_blurbs">Evan Johnson</a></li>
</ul>
</div>
</div>
<!-- /.row -->
</div>
<!-- /.container -->
<script src="js/003.1-lexical.js"></script>
</body>
</html>