Skip to content

Commit 3f31457

Browse files
committed
use variable before it is declared through var
1 parent e6a318e commit 3f31457

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Hoisting.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<body>
5+
6+
<h2>JavaScript Hoisting</h2>
7+
8+
<p>With <b>var</b>, you can use a variable before it is declared:</p>
9+
10+
<p id="demo"></p>
11+
12+
<script>
13+
carName = "Volvo";
14+
document.getElementById("demo").innerHTML = carName;
15+
var carName;
16+
</script>
17+
18+
</body>
19+
20+
</html>

0 commit comments

Comments
 (0)