forked from js-workshops/scope-and-closure
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path001.4-scope.html
55 lines (51 loc) · 2.46 KB
/
001.4-scope.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Scope</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">IIFE</h1>
<p class="lead">What's the difference between an IIFE and a normal function expresion?</p>
</div>
<div class="col-lg-12">
<blockquote>
<p>IIFE: Imediatly-Invoked Function Expression</p>
</blockquote>
<ol>
<li>Open <kbd>js/001.4-scope.js</kbd> in Sublime Text.</li>
<li>Add a console log statement to the IIFE on line 3:
<pre>console.log("your log statement here");</pre></li>
<li>Add a different console log statement to the <code>nonIIFE</code> function on line 8.</li>
<li>Open the console and notice which statement is logged.</li>
<li>Invoke the <code>nonIIFE</code> function to have your second statement logged:
<pre>nonIFFE();</pre></li>
</ol>
</div>
<div class="col-lg-12 text-center footer">
<ul class="list-unstyled">
<li><a href="001.3-scope.html"><< Prev</a> | <a href="002-lab.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/001.4-scope.js"></script>
</body>
</html>