-
Notifications
You must be signed in to change notification settings - Fork 0
/
functionStatement.html
54 lines (47 loc) · 1.43 KB
/
functionStatement.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
<!doctype html>
<html lang="en">
<head>
<meta charset="iso-8859-15">
<link rel="DCTERMS.isReferencedBy" href="http://jibbering.com/faq/#functionStatement">
<title>Function Statement Example - FAQ - comp.lang.javascript</title>
<style type="text/css">
pre {
background: #fefefe;
padding: 1ex;
border: 1px dashed #eee;
}
</style>
</head>
<body style="background: #f9f9f9">
<h1>Function Statement Example - FAQ : "What is a function statement?"</h1>
<h2>Example Code</h2>
<pre>
try {
x; // ReferenceError: x is not defined.
function Fze(a, b) {a.unselectable = b}
} catch(e) { }
document.write("typeof Fze: ", typeof Fze, "\ntypeof e: ", typeof e);
</pre>
<h2>Result</h2>
<pre>
<script type="text/javascript">
try {
x; // ReferenceError: x is not defined.
function Fze(a, b) {a.unselectable = b}
} catch(e) { }
document.write("typeof Fze: ", typeof Fze, "\ntypeof e: ", typeof e);
</script>
</pre>
<p>
Expected outcome for <code>typeof Fze</code> is not specified by ECMA-262.
</p>
If <code>typeof Fze</code> results <code>"function"</code>, then <code>Fze</code> was interpreted
as a FunctionDeclaration. Otherwise if <code>typeof Fze</code> resulted <code>"undefined"</code>,
then <code>Fze</code> was not reached as a Statement; the preceeding statement - <code>x;</code> -
would trigger a ReferenceError, making it unreachable.
</p>
<p>
Expected outcome for <code>typeof e</code> is <code>"undefined"</code>.
</p>
</body>
</html>