MIRROR: javascript for 馃悳's, a tiny runtime with big ambitions
1function hoist1() {
2 b(); // b is hoisted from below
3 function b() {
4 console.log('b');
5 }
6}
7
8function hoist2() {
9 b(); // b exists but is undefined
10 var b = function b() {
11 console.log('b');
12 };
13}
14
15function hoist3() {
16 b(); // b does not exist
17 let b = function b() {
18 console.log('b');
19 };
20}
21
22try {
23 hoist1();
24} catch (err) {
25 console.log(err);
26}
27
28try {
29 hoist2();
30} catch (err) {
31 console.log(err);
32}
33
34try {
35 hoist3();
36} catch (err) {
37 console.log(err);
38}